dushyant.agarwal 0 Posted May 18, 2010 Report Share Posted May 18, 2010 Hi,I would like to get opinion on which approach among Pixels(pix or px), Point(pt) or Percentage(%) is the best practice, while giving widths and heights in .html files or CSS.Thanks. Quote Link to post Share on other sites
chibineku 0 Posted May 18, 2010 Report Share Posted May 18, 2010 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. Quote Link to post Share on other sites
ShadowMage 94 Posted May 18, 2010 Report Share Posted May 18, 2010 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. Quote Link to post Share on other sites
thescientist 231 Posted May 18, 2010 Report Share Posted May 18, 2010 (edited) 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 May 18, 2010 by thescientist Quote Link to post Share on other sites
boen_robot 107 Posted May 18, 2010 Report Share Posted May 18, 2010 ... 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. Quote Link to post Share on other sites
Guest Evanion Posted June 7, 2010 Report Share Posted June 7, 2010 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). Quote Link to post Share on other sites
Ingolme 1,020 Posted June 8, 2010 Report Share Posted June 8, 2010 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. Quote Link to post Share on other sites
music_lp90 1 Posted June 10, 2010 Report Share Posted June 10, 2010 I reset the font to 62.5% in the body so that 1em is 10 pixels.Thanks, Inglome. I think I will start doing that. Quote Link to post Share on other sites
Fmdpa 9 Posted June 11, 2010 Report Share Posted June 11, 2010 Is "pix" valid? Quote Link to post Share on other sites
Synook 47 Posted June 11, 2010 Report Share Posted June 11, 2010 No (however, some user agents may default to pixels if an unrecognised unit is specified). Quote Link to post Share on other sites
ballack999 0 Posted June 17, 2010 Report Share Posted June 17, 2010 px 's useful for showing on monitor.pt 's useful for printing.px 's not influential in printing it's only for monitor Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.