All the CSS sizing units you didn’t know existed

2015-11-11

If you’re a front-end developer/designer, you probably know px and em sizing units. But did you know there’s 15 of them?

  1. em: This unit represents the calculated font-size of the element. If used on the font-size property itself, it represents the inherited font-size of the element.
  2. ex: This unit represents the x-height of the element’s font. On fonts with the ‘x’ letter, this is generally the height of lowercase letters in the font; 1ex ≈ 0.5em in many fonts.
  3. ch: This unit represents the width, or more precisely the advance measure, of the glyph ‘0’ (zero, the Unicode character U+0030) in the element’s font.
  4. rem: This unit represents the font-size of the root element (e.g. the font-size of the element). When used on the font-size on this root element, it represents its initial value.
  5. vh: 1/100th of the height of the viewport.
  6. vw: 1/100th of the width of the viewport.
  7. vmin: 1/100th of the minimum value between the height and the width of the viewport.
  8. vmax: 1/100th of the maximum value between the height and the width of the viewport.
  9. px: Relative to the viewing device.
  10. mm: One millimeter.
  11. cm: One centimeter (10 millimeters).
  12. in: One inch (2.54 centimeters).
  13. pt: One point (which is 1/72 of an inch).
  14. pc: One pica (which is 12 points).
  15. mozmm: An experimental unit which attempts to render at exactly one millimeter regardless of the size or resolution of the display. This is rarely actually what you want, but may be useful in particular for mobile devices.

Source: https://developer.mozilla.org/en/docs/Web/CSS/length