Quick! CSS question!

Out of context: Reply #1

  • Started
  • Last post
  • 6 Responses
  • dc0

    bit of a complicated one really...

    "em" stands for "em-height" which are common typographical measurements, however, in CSS they have meaning you may not expect if you are familiar with typography.

    one "em" is the value of font-size for a given font - so if the font-size is 14 points, then one "em" for that element is 14 points. so you may set the margin for a paragraph of 18point text as 1em - this would give a margin of 18 points.

    furthermore, when setting the font. "em" is relative to the parent element. so you may set a class for some small print, which is slighly smaller that the surrounding text. in which case you could say:

    small {font-size: 0.8em;}

    the moral of the story is, stop wondering about what "em" is and stick with points and pixels!

View thread