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) The Box Model Padding

using percetage in padding css

hello every body i cant figure out why is using % in padding value nessary because when i used px and % and resized my browser it is the same effect !! any help please ? thanks in advance :)

1 Answer

Steven Parker
Steven Parker
231,271 Points

If you use pixel (px) values, the amount of padding will always be the same no matter what the window size is.

But if you use percentage (%) values, then the padding will vary based on how big the window is. This is one of the techniques used in "responsive design".

Try stretching and shrinking your browser window to see how it works.