Jump to content

Pixels(pix or px), Point(pt) or Percentage(%), which is best practice?


Recommended Posts

They all have a place (as do ems), and it depends what you want to do. If you want your content to be a certain proportion of the page, you use %, whereas if you want a fixed width layout, you'd use px. I don't think there are any hard and fast rules - you just use whatever gives you the effect/accuracy you want.

Link to post
Share on other sites

Depends on what effect you want to achieve. When you use pixels you set a static dimension. That width/height will never change regardless of browser window size or screen resolution. If you use percents or ems, you'll get a 'fluid' effect. Which means that the elements dimensions will change depending on the window size and screen resolution. The em measure is relative to font size, though I'm not 100% sure what the relationship is.

Link to post
Share on other sites

It is representative of the the letter 'm' I believe, maybe since it is the widest letter? Anyway, its relative to the current font size and acts as a multiplier, of sorts.http://www.w3schools.com/css/css_units.asp

Edited by thescientist
Link to post
Share on other sites

... current size (in general), not just for fonts I think. 1em is the size that would be if you don't specify anything. 2em is two times that size. I mean just try to use ems on a box... it should work.

Link to post
Share on other sites
  • 3 weeks later...
Guest Evanion

Best practice would be (in my meaning), to specify font:100% in body, and then use ems (at 100% 1em=16px) for text and minor layout stuff. and px/% for layout where applicable.There is no ONE best unit, if there was ... the rest would get deprecated. But as a rule of thumb, 'reset' the font size to 100% in body, and then use ems to set the final size. Ems are more compatible with support systems for people with bad eyesight and was introduced as a mix between px and % (or so I have heard).

Link to post
Share on other sites
Best practice would be (in my meaning), to specify font:100% in body, and then use ems (at 100% 1em=16px) for text and minor layout stuff. and px/% for layout where applicable.There is no ONE best unit, if there was ... the rest would get deprecated. But as a rule of thumb, 'reset' the font size to 100% in body, and then use ems to set the final size. Ems are more compatible with support systems for people with bad eyesight and was introduced as a mix between px and % (or so I have heard).
I reset the font to 62.5% in the body so that 1em is 10 pixels.
Link to post
Share on other sites

No (however, some user agents may default to pixels if an unrecognised unit is specified).

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...