Home

5em

5em is a CSS length unit that equals five times the font size of the element to which it is applied. As an em-based unit, its exact value depends on the element’s computed font-size and can change with inheritance and nesting.

For example, if an element has a font-size of 16px, 5em equals 80px. If the font-size is

Because em units are relative to the element, sizes defined in ems can compound through nesting. A

Common uses include scalable margins, padding, and widths that visually adjust with text size. However, using

12px,
5em
equals
60px.
If
a
child
element
uses
font-size:
1.5em
within
a
parent
of
16px,
the
child
font-size
becomes
24px;
a
5em
value
on
that
child
would
be
120px.
child’s
font-size
defined
in
ems
depends
on
its
parent’s
font-size,
and
any
em-based
values
on
that
child
scale
accordingly.
To
avoid
cascading
changes
tied
to
the
root
font-size,
some
developers
prefer
rem
units,
which
are
relative
to
the
root
element’s
font-size.
5em
for
line-height
or
other
vertical
metrics
can
produce
excessive
spacing
if
not
carefully
tested.
As
with
all
em-based
values,
it
helps
to
test
layouts
across
devices
and
user
font-size
preferences
to
ensure
predictable
behavior.