March 11, 201214 yr I have allways used px for my div heights etc. Should i be using % so that its the same in all screen res etc?
March 11, 201214 yr This is completely scenario dependant. That's why we have pixels, ems, percentages etc. If you want something 300px tall, set it to 300px. If you want it the height of the container, set it to 100%. Most block elements I'll use pixels. I feel like I have more control design wise as my site will be pixel perfect. You can use percentages but also set max/min-width in pixels. If you're worried about extreme changes in resolution (looking good on mobile as well as a 30" display) look into responsive layouts. They're extremely easy to make and are impressive as hell. Also look at a decent css grid system. Ems are associated with type and are more like percentages than they are pixels. Always do line-height in percentages for scalability (or just unitless em values such as 1.5 - I've been told that works). Using percentages for type also gives you design flexibility if you want your headers to be 3x the size of paragraph text then set it to 300%. TL;DR: It depends completely. Ask yourself which would be more suitable. They're all acceptable! Edit: Formatting Edited March 11, 201214 yr by Ashley Byrom
March 11, 201214 yr Author Thanks for the reply Didnt want to get into bad habbits early on. I prefer using px as well, was just checking Thanks for all the info!
March 12, 201214 yr Although pixels are easier to use, percentages and ems are sometimes considered more suited to the market these days as devices and screen sizes vary drasticly. Here's an interesting article about it if you're up for some reading: fluid layouts I use ems for anything type based, pixels when fixed width images are involved, and percentages for general layout.
Create an account or sign in to comment