Jump to content

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


dushyant.agarwal

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 comment
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 comment
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

Link to comment
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 comment
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 comment
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 comment
Share on other sites

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...