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 How to Make a Website Responsive Web Design and Testing Responsive Web Design

How do i know whether an element suits "px" or "%" ? PLEASE ,,

.

3 Answers

Andrew McCormick
Andrew McCormick
17,730 Points

my rule of thumb is if I want the element to resize or not.

it's seemingly make sense. I spent a time thinking about that. However, could u please throw more light on it ?

Herb Bresnan
Herb Bresnan
10,658 Points

Right. px is fixed and will remain the same size. % will resize to a percentage of the parent element.

Well, here's what I think, use mostly % to keep your design fluid, but assign px measurements to add more control over the sizing. Let say you are inserting something like an image tag and you know your photo file is 720 px wide, so you give the img a max width 720 px and a width in percentages of maybe 45%. What this is saying is hey img be 45% of the page until you hit your max width of 720 px, then stop there.

Hope this helps.