Posted By

alozuldo on 10/24/10


css em conversion body font-size px

Versions (?)

Who likes this?

4 people have marked this snippet as a favorite


Set body font-size to 62.5% for Easier em Conversion

 / Published in: CSS


If you would like to use relative units (em) for your font sizes, declaring 62.5% for the font-size property of the body will make it easier to convert px to em. By doing it this way, converting to em is a matter of dividing the px value by 10 (e.g. 24px = 2.4em).

  1. body {
  2. font-size: 62.5%; /* font-size 1em = 10px */
  3. }
  4. p {
  5. font-size: 1.2em; /* 1.2em = 12px */
  6. }

Report this snippet  

You need to login to post a comment.