Font-dependent units

Back to the index.

This script does not work in IE8 and lower.

Controls

Root font size:

font-family:

Below you see how many pixels the units are for the base fonts of 12, 16, and 24 pixels. Select a font to generate this data.

This is the test page for the “font-dependent” CSS units. In fact, only ex and ch are truly font-dependent; em and rem aren’t.

The dotted line is the right border of the test wrapper. If an element is exactly as wide as the test wrapper, the unit is not supported.

font-size: 12px

Test area with font-size: 12px.

width: 20em

width: 20ex

width: 20ch

width: 20rem

font-size: 16px

Test area with font-size: 16px.

width: 20em

width: 20ex

width: 20ch

width: 20rem

font-size: 20px

Test area with font-size: 20px.

width: 20em

width: 20ex

width: 20ch

width: 20rem

font-size: 24px

Test area with font-size: 24px.

width: 20em

width: 20ex

width: 20ch

width: 20rem