em, px or %

aka Rohan's picture

He has: 200 posts

Joined: Feb 2006

I'm currently creating a new intranet page for the company I work for but am not sure which is the best way to size the elements.

The current pages I maintain were originally written using 'em' for the sizing. These pages are really just tables so whether that makes a difference in choice i'm not sure. My page is currently scaled in pixels.

I guess I have two questions really.

1. What is 'em' in relation to sizing of divs for layouts.
2. when/why would you use 'em' and '%' for sizing over 'px'.

Cheers Smiling

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

Personally, I prefer to use em over the % (I never use px, it's a little silly). This is because % is based on the relative width of its container. Where as, an em is based on a letter.

In case you're wondering how big an "em" is, try typing in the letter "m" in 12pt size. That's how big an "em" is. It is used because it is the widest and squarish letter in the English alphabet (an "em space/block" is 12pt high and 12pt wide) . An "en" is half the size of an "em." If you type in an "n" you'll see why.

They have: 1 posts

Joined: Dec 2006

depends on your needs. if you design a pre-sized website then use px. I use % because I usually try to design websites to fit different kind of resolutions.

בניית אתרים במחירים נוחים לכל עסק
Graphic design New-York

aka Rohan's picture

He has: 200 posts

Joined: Feb 2006

Thanks for the help guys. I've just changed all the px to ems. It probably would have all been fine as it was but I like to do things correctly wherever possible. Smiling

He has: 1,758 posts

Joined: Jul 2002

I use em's for text styling and pixels and percents for the site layout. That's kinda how they're designed to be used. (although if you use ems for everything, when you increase the text size the rest of the site scales with it which is pretty cool!)

Andy

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.