LuluDev
asked on
When to use px vs em vs in ...on a margin property?
I am confused on when to use em or px when setting margin property on elements. For font settings I have been told that em is best to use as a general rule. But I see for margins a common setting seems to be in pixels (px). How do I determine whether I should use px or em for a margin? Is there a general rule for margin unit of measurement choices (px, em, in)?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank-you for your responses and clarifications.
http://www.w3.org/TR/CSS21/syndata.html#value-def-length
I guess you got it mixed up with "ex", which is equivalent to the height of a lower case "x".
Typography can be confusing.
http://en.wikipedia.org/wiki/Em_%28typography%29#Incorrect.2FAlternate_Definitions
<< One em is sometimes said to be equal to the WIDTH of a capital "M". >>
Anyway, it's easier to simply think of it as the font-size of the current element without any other reference.
This does not change much for this particular question...
I agree with the rest of your first post. People use "px" because they don't know better. Just like people design fixed-width pages because they don't know how to code a liquid layout properly.
Actually, for font-size, i prefer to use percentages. The result is exactly the same (font-size:1.5em is equivalent to font-size:150%). Percentages just make more sense to me.
I guess you got it mixed up with "ex", which is equivalent to the height of a lower case "x".
Typography can be confusing.
http://en.wikipedia.org/wiki/Em_%28typography%29#Incorrect.2FAlternate_Definitions
<< One em is sometimes said to be equal to the WIDTH of a capital "M". >>
Anyway, it's easier to simply think of it as the font-size of the current element without any other reference.
This does not change much for this particular question...
I agree with the rest of your first post. People use "px" because they don't know better. Just like people design fixed-width pages because they don't know how to code a liquid layout properly.
Actually, for font-size, i prefer to use percentages. The result is exactly the same (font-size:1.5em is equivalent to font-size:150%). Percentages just make more sense to me.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry for any confusion.