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 trialJosh McMullin
3,012 PointsShouldn't the max-width of the #wrapper div be in % and not px?
How do you know when to use px and not % for a page as a general rule? Also, Nick says we're setting the #wrapper div to 940px. What is the actual width of this page?
2 Answers
Joel Bardsley
31,249 PointsHey Josh, hopefully this will help:
While you could set a % max-width to the wrapper ie 90%, it's better practice and more manageable to keep the wrapper at the div's native 100% width and then use padding or margin to keep content away from the edges (you'll notice in the video that Nick applied a 5% padding to the left and right to do that.
The max-width will depend on your chosen design. While you can absolutely have it set as a percentage, the percentage might look great for desktop but be completely unsuitable for smaller devices, or vice-versa. Instead of setting different widths at different screen sizes, a width is only being set once.
The next video in the series has Nick discussing a mobile-first approach so you'll be able to see that he's deliberately keeping everything as simple as possible from the start.
Josh McMullin
3,012 PointsHi Joe,
I guess my question is how did make the determination to set the max-width to 940px? Was that based off an assumption that there is a default page body width?