The lh
and rhl
units
html: line-height
html { font-size: 1.1rem; line-height: 1.4; }
line-height: 1.4;
: This sets the line height for the entire HTML document relative to the font size. Aline-height
of 1.4 means the space between lines of text is 1.4 times the font size. This improves readability by providing adequate spacing between lines.
section: padding
section { padding: 2rlh; margin-trim: block; }
padding: 2rlh;
: This sets the padding inside eachsection
element. The value2rlh
uses therlh
(root line height) unit, which is calculated based on theline-height
of thehtml
element. Givenhtml { line-height: 1.4; }
, the root line height (rlh) becomes 1.4 times the root font size. Here,2rlh
means padding is set to twice the root line height.
h1, p: margin-block
h1 { font-size: 2rem; line-height: 1.2; } h1, p { margin-block: 1rlh; }
margin-block: 1rlh;
: This sets the margin on both theblock-start
andblock-end
(top and bottom) ofh1
andp
elements to1rlh
. The value1rlh
uses therlh
(root line height) unit and it ensures consistent vertical spacing relative to the root line height. Given thehtml { line-height: 1.4; }
,1rlh
corresponds to a margin equal to the root line height, facilitating consistent and proportional spacing.

Summary
html
element: Sets a global line height of 1.4, establishing the base root line height (rlh) for the document.section
element: Applies padding based on twice the root line height (2rlh
) and trims margins.h1, p
elements: Assigns a block margin of1rlh
, ensuring proportional and consistent vertical spacing relative to the root line height, enhancing the layout’s readability and visual balance.
The result is a vertical rhythm that matches the height of a line of text even though no actual text is present between elements.
Leave a Reply