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 trialYongyu Zhang
1,892 PointsI can't understand the "viewport" part of "responsive web design".
<meta name="viewport" content="width=device-width initial-scale=1.0">
How does it work?
2 Answers
Erik S.
9,789 PointsHi, W3Schools explains it quite nicely and has some example images.
Justin Farrugia
13,649 PointsAs Erik points out W3Schools has a pretty good explanation.
Quoting from their explanation, "the viewport is the visible area of a webpage which varies with devices". Before HTML5 came about, many people just resized their webpage to a smaller scale to fit tablets or mobile phones to fit the screen. Then when HTML5 introduced control over the viewport within the meta tag, it was possible for developers and designers to control that scaling and the dimensions.
<code>meta name="viewport" content="width=device-width, initial-scale=1.0"</code>
So now when it came to making a website responsive, HTML5 gave us the ability to set the width of the page to be proportional to the screen width of the device regardless of what it might be, whereas the initial-scale part sets the zoom level when the page is loaded.
Anyways you should really check out that explanation over there, they do a pretty good job explaining it with images
Yongyu Zhang
1,892 PointsThank you!
Yongyu Zhang
1,892 PointsYongyu Zhang
1,892 PointsThank you!