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 CSS Basics (2014) Enhancing the Design With CSS Adjusting the Layout with Media Queries

pat barosy
pat barosy
6,759 Points

Why use percentages for padding in .wildlife & pixels for padding everywhere else?

Hello,

I still do not understand why we are using percentages for the padding values of the wildlife class & using pixels for the padding values of every other section. I understand what the percentages do in relation to browser resizing, but I don't understand the reasoning for using them only here.

Thank you

2 Answers

Max Senden
Max Senden
23,177 Points

Hi Pat,

There are many videos on Treehouse that make you wonder why they did something instead of doing something else. The best suggestion that I can give you is to do it the way you think it should be done. It's a good way to learn why they do the things that they do.

In this particular case switching the percentage values in the padding with pixels causes some issues on various screen sizes. If you use pixels you'll see .wildlife getting a bit scrambled as you test it on phones screens. It might even feel claustrophobic. By using percentages it'll stay neat and clean on all devices with the text having plenty of air to breath. This doesn't mean using pixels would be a bad thing. It's just that using percentage values gives better results.

Hope it helps, Max

pat barosy
pat barosy
6,759 Points

Max, Thanks so much for the response and explanation
One last question. Why is padding percentage needed in .wildlife & not anywhere else. What is the thing about .wildlife that causes it to require padding in percentages? Is it something that i can identify before using trial & error? Why would resizing negatively affect THAT specific div & not others?