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
Srdjan Cestic
6,855 PointsReview of my code and difference between % and px
Hi, is this code good? Please see my workspace and final result. Here's a link of my workspace: https://w.trhou.se/08h9fos0ca
And why Nick sometime use % and sometimes pixels, what's difference? Can I only use %, or is better to ''mix''?
Thanks in advance!
1 Answer
Srdjan Cestic
6,855 PointsSo the best way is to use % for creating responsive web design?
% for width, margin, padding and em for font-size, am I right?
Regards
Jesus Mendoza
23,289 PointsJesus Mendoza
23,289 PointsHey Srdjan, % is depending of the size of the container and pixels will always be the same size. For example: Let's say your body has a height of 300px and you make a div inside it, if you set the div's height to 50% it will be equal to 150px and since you set the height of the body 300px it will never change, no matter if you resize your window browser.
% can also be used to create fluid websites. How? Let's say you make the body 100% height, it's height will change depending of the size of the window of your browser.