What is em exactly relative to?
Sun Sep 25 2022 17:58:12 GMT+0000 (Coordinated Universal Time)
Saved by
@amolchopra
em is relative to font size of parent. HOWEVER, it is relative to its own element if it is applied to anything else other than font size. Below is example
section {
font-size: 18px
}
.abc {
font-size: 1.5em;
}
section {
font-size: 18px
}
.big-abc {
font-size: 10px;
}
.abc {
padding: 1em; //here paddingwill be relative to .big-abc and not section tag
}
<section>
<h1 class = "abc big-abc"></h1>
</section>
content_copyCOPY
Comments