There isn't a set conversion from ch
to px
, as ch
is a relative unit just like rem
and em
. One ch
represents the width of the 0
glyph (ZERO, U+0030) in the current font.
If the width of the 0
glyph is 8px, then 1ch = 8px
(in this example, it's also equal to 0.5em, but that may vary).
html {
font-size: 16px;
}
.font-20 {
font-size: 20px;
}
.em {
background: red;
height: 1em;
width: 1em;
}
.rem {
background: blue;
height: 1rem;
width: 1rem;
}
.ch {
background: green;
height: 2ch;
width: 2ch;
}
.px {
background: orange;
height: 16px;
width: 16px;
}
<div>
<h1>font-size: 16px (root size)</h1>
<div class="ch" title="2ch"></div>
<div class="em" title="1em"></div>
<div class="rem" title="1rem"></div>
<div class="px" title="16px"></div>
</div>
<div class="font-20">
<h1>font-size: 20px</h1>
<div class="ch" title="2ch"></div>
<div class="em" title="1em"></div>
<div class="rem" title="1rem"></div>
<div class="px" title="16px"></div>
</div>