CKTIS / CSS
rch — the root element’s ch unit
The rch length unit equals ch on the document’s root element. It sizes elements using root font metrics rather than the local font size.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
<number>rch1rch equals 1ch on the document’s root element, usually html. The ch unit uses the advance measure of the 0 glyph (U+0030) along the inline axis, not the width of its visible outline.
Unlike ch, rch does not use local font metrics. It is also distinct from rem, which refers to the root font size. 10rch does not guarantee room for ten arbitrary characters.
The example compares the 10rch width of #sample with the 10ch width of #reference. The sample has font-size: 40px, while the reference inherits font-size: 20px from the root. The widths are expected to match: rch uses the root font metrics, and ch on the reference uses those same metrics. The exact pixel values depend on the selected monospace font. Unit support and the result require local verification.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>rch — root character width</title>
<style>
html { font: 20px monospace; }
.bar { height: 1rem; background: teal; }
#reference { width: 10ch; }
#sample { font-size: 40px; width: 10rch; }
</style>
</head>
<body>
<div id="reference" class="bar" aria-hidden="true"></div>
<div id="sample" class="bar" aria-hidden="true"></div>
<script>
if (!CSS.supports('width', '10rch')) {
console.log('rch unsupported');
} else {
const reference = getComputedStyle(document.getElementById('reference'));
const sample = getComputedStyle(document.getElementById('sample'));
const matches = parseFloat(reference.width) > 0 &&
sample.width === reference.width && sample.fontSize !== reference.fontSize;
console.log(`rch supported; matches ch at the root font size: ${matches}`);
}
</script>
</body>
</html>Result
rch supported; matches ch at the root font size: true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.