Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

rlh — root line-height unit

The rlh unit expresses a length relative to the root element’s line-height, not that of the element using it.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

<number>rlh

1rlh equals the root element’s lh unit. Unlike lh, it does not depend on the local line-height; rem instead refers to the root element’s font-size.

With line-height: normal, the basis comes from the first available font’s metrics. A height of 2rlh does not guarantee room for exactly two actual lines: their size also depends on content.

On the root element, using rlh in line-height or font-affecting properties refers to initial-value metrics to avoid a circular dependency.

In the example, the root’s explicit line-height: 24px produces a width of 48px and a height of 24px. The local line-height: 40px does not change these dimensions.

Examples

<!doctype html>
<meta charset="utf-8">
<title>rlh</title>
<style>
  :root { font-size: 16px; line-height: 24px; }
  .box {
    line-height: 40px;
    width: 2rlh;
    height: 1rlh;
    background: teal;
  }
</style>
<div class="box"></div>

Result

width: 48px; height: 24px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources