🌐Viewport Meta Tag
Also known as Meta Viewport, width=device-width, Viewport Meta Element
One line of HTML that makes a page fit the width of a phone screen.
Think of it like
It is like telling a tailor your real size. Then the shirt fits you, not a giant.
Example
Jack's new site looks tiny on his phone, and his mobile styles never kick in. He adds the viewport tag, and the page fits.
Why it matters
It is the first step of any page that works on phones. Without it, responsive design does not work at all.
Definition
Example code
html
<meta name="viewport" content="width=device-width, initial-scale=1">Common mistake
Key takeaways
- 1One line. It goes in the head of the page.
- 2Real width. The page is laid out at the screen width.
- 3Let people zoom. Never turn zoom off.