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

HTML How to Make a Website CSS: Cascading Style Sheets Center the Wrapper

Ivan Franzone
Ivan Franzone
7,328 Points

Padding: Why "%"?

Hello guys! Why on the padding value we´re using % and not px? What it would be the difference? Thanks in advance!!

1 Answer

Mikkel Rasmussen
Mikkel Rasmussen
31,772 Points

pixel is static so that means it will be the same pixel on different devices with different screen resolutions. But percent will vary from screen resolutions so that means if you set a padding to 10 %;

It could look like 100 pixels in your screen but on mine it would only be 30 pixels and that because you have higher resolution than I have - and the other way around of course :)

I hope this helped you understand :)

Ivan Franzone
Ivan Franzone
7,328 Points

Thanks you very much Mikkel. Very clear! ;)

Mikkel Rasmussen
Mikkel Rasmussen
31,772 Points

Remember to choice this as the best answer if you think it was clear enough :)