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 trialAndy tran
7,112 Pointswhen do we use px ?and when do we use %?
im not sure when to use px and when to use percentage
2 Answers
Jake Milburn
13,608 PointsI might be wrong but I just use them interchangeably. I tend to prefer percentages as when you resize your browser windows or if you were on a different device the content will change to the percentage of the viewport. If you use pixels and resize your browser the things that you have applied the size to will not change to match the window and may end up being unproportional to the page size.
Andre Johnson
4,148 Pointsi think you should only use px when you know the size of the screen if what ever it is you're deploying to. also if you believe that the screen size may change sometime in the future you should not use px. for everything else use a relative unit.