em unit

noun

say it: “EM YOO-nit” /ɛm ˈjunɪt/

A CSS unit of size equal to the font size of the element it's used on (for font-size itself, the parent's font size), so 2em on 20px text is 40px.

What is the em unit?

An em is the current element's font size. 2em means twice the font size, so spacing grows with the text.

.button { font-size: 18px; padding: 0.5em 1em; }   /* 9px 18px */

In a sentence

  • “I set the button's padding with the em unit, so bigger buttons get more padding without any extra rules.”

Level: Novice · More CSS terms at this level

Updated