Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS How to Make a Website Responsive Web Design and Testing Adjust the Profile Page and Header

"meta" what ?????????

at the end of the last video I watched, this code came up. I replayed the explanation about 5 times and still don't get the meaning of this code line

<meta name="viewport" content="width=device-width, initial/scale=1.0">

can please someone explain?!?!? thank you

4 Answers

Michael Lauridsen
Michael Lauridsen
10,321 Points

The content="width=device-width" basically controls the size of the viewport. So it sets the width, to the device width of the mobile / tablet. This means that the width will be for an example, 640px instead of being zoomed all the way out. The "initial-scale=1" sets the zoom level to 1 when loaded, so the user starts with a zoom level of 1.

So that means my webpage always renders down to the viewport of a mobile/tablet. So that it doesn't occur that my webpage is suddenly super small and unreadable on a mobile?

So that means my webpage always renders down to the viewport of a mobile/tablet. So that it doesn't occur that my webpage is suddenly super small and unreadable on a mobile?

Michael Lauridsen
Michael Lauridsen
10,321 Points

Yup! It was introduced when browsing on the phone became a thing.

Ulises Calvo
Ulises Calvo
2,233 Points

Does this mean when we zoom in and out our first media queries in, say Chrome on our desktop it works only for the purpose of testing, but if we were to go live without adding that meta chunk of code the website would appear super tiny?

Caden Adam
Caden Adam
16,257 Points

The short answer is no (to a degree). Most of the latest phone browsers will know what you're talking about without the <meta> tags, but it's ideal practice to have them in your site to stop them from breaking and having compatibility issues across different browsers especially when it comes to webkits and moz queries. Without them it'll be a lot less fluid and responsive overall.