About em?

body {
    font-size: 20px;
    line-height: 2;
}

.em {
    font-size: 2em;
    background: -sharpccc;
}

how much should the line-height above be in the end?
I"m not sure:
.em inherits the line-height property of body, does it inherit the value of 2? Or do you inherit the calculated 40px?

Jul.04,2021

inherits the attribute 2, that is, 2 * 20 = 40px after calculation. You can query it from the developer's tool:
clipboard.png


.em line-height2bodyline-height40px,.em80px


font-size, font-size, font-size, emfont-size.
line-height:

clipboard.png

.
Menu