Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Basics (2014) The Box Model Padding

Sahar Nasiri
Sahar Nasiri
7,454 Points

Percentage size of paddings

I didn't understand the differences between percentage size and pixel size of the paddings!

2 Answers

Huseyin INAN
Huseyin INAN
170 Points

Opps my html answer was striped by system software.

You can see what I say on https://css-tricks.com/forums/topic/responsive-web-design-when-to-use-px-vs-on-margins-and-padding/

Generally, I use bootstrap or materializecss for responsive web sites. If you like it, can use them.

Huseyin INAN
Huseyin INAN
170 Points

Generally you will use pixel size for paddings. But, if you use percentage, your element padding will be flexible according to parent element.

Example: (paddings will be 10px) <div style="width: 100px; height: 100px"> <div style="width: 90px; height: 90px; padding:10px">Content</div> </div>

Example: (paddings will be 5px) <div style="width: 100px; height: 100px"> <div style="width: 90px; height: 90px; padding:5%">Content</div> </div>

Example: (paddings will be 10px) <div style="width: 200px; height: 200px"> <div style="width: 90px; height: 90px; padding:5%">Content</div> </div>

Sahar Nasiri
Sahar Nasiri
7,454 Points

Thank you :) But can you tell me how can I see the difference operated on my page? Because when I resize the page both operating similarly.