Let's look at an example:
In the above example, the width and
height of h1
were calculated based
on h1
's font size.
Though one thing different here is that,
the font-size
itself is given in em
.
So the font-size
value of h1
now depends on the font size of its parent element.
When we don't set a font size on
a parent element or any of its ancestors,
the default font size
of the browser will be used.
In most web browsers, the default font size
is 16px, unless the default browser settings
are changed.
In the above example, since the parent element
doesn't have a specified font size, it will
inherit the default font size from the browser.
So, the width and height of the child element are
calculated based on the div
's font-size
.