offline version v3


175 of 298 menu

em unit

The em relative unit sets a font size of a child element based on the size of its parent. For example, a font equal to 2em means that it is twice the size of its parent.

Example

Let's give the text of the <p> element a font one and a half times larger than the font of its parent <div>:

<div> text1 <p> text2 </p> </div> div { font-size: 14px; } p { font-size: 1.5em; }

:

See also

  • the px unit
    that specifies a size in pixels
  • the fr unit
    that specifies a size in fr
  • the rem unit
    that specifies a size in rem
  • the % unit
    that specifies a size in percentage
  • the vw unit
    that specifies a size in vw
  • the vh unit
    that specifies a size in vh
  • the vmax unit
    that specifies a size in vmax
  • the vmin unit
    that specifies a size in vmin
enru