The size of an element in em does not change with the type of the font, as it changes for ex or ch. Even hard different types of fonts have different sizes of "M".
<div id="em1">Font Serif with em as units</div>
<div id="em2">Font Sans-Serif with em as units</div>
<div id="ex1">Font Serif with ex as units</div>
<div id="ex2">Font Sans-Serif with ex as units</div>
<div id="ch1">Font Serif with ch as units</div>
<div id="ch2">Font Sans-Serif with ch as units</div>
body {
padding: 20px;
}
width: 25em;
height: 40px;
background: orange;
margin: 20px;
}
width: 50ch;
height: 40px;
background: orange;
margin: 20px;
}
width: 50ex;
height: 40px;
background: orange;
margin: 20px;
}
font-family: Serif;
}
font-family: Sans-Serif;
}
Refer to this fiddle for more information. You may notice different Div sizes for ch and ex with the same width size but with a different font type, but this is not the case for em.
source
share