When doing flexible layouts, there is no way around using relative sizes, so that fonts and elements resize accordingly.

CURRENT RELATIVE UNITS

  • EM
    Relative to the font-size of the element. The information comes from the browser preset.
  • REM (not supported in older browsers, like IE 8)
    Relative to font-size of the root element
  • PERCENT
    Relative to the container

CALCULATION

If not set differently, 1 em equals 16 Pixel in most browsers, which gives us a calculation basis.

Preset value = 16PX = 100% or 1EM or 1 REM

So 1/16 = 0,0625 is our calculation factor.

EM VS REM

The difference between EM and REM is the inheritance.

The REM value is calculated in reference to the root element, the font size of the HTML, not the BODY,  element.

The EM value is calculated in reference to its parent element.

SUPPORT

Due to limited support in older browsers, you can use graceful degradation in your stylesheet to use both.

The Pixel value must be added before the REM value !

Enjoy coding …