CSS inline box 2026-11-05
A CSS inline box is the box generated by an inline CSS non-replaced element, such as a text element styled with
display:inline. It participates in a CSS inline formatting context. When line breaking splits its content, fragments can occur on several CSS line boxes.[ref]For vertical line layout, its
line-height and the CSS leading calculation determine its allocated extent. A child can contribute a taller box to the same CSS line box without changing the parent's own allocated height. For example, take a parent with line height 14 CSS pixels and baseline extents 10 above and 4 below. A child with line height 24 and extents 17 above and 7 below enlarges the enclosing line to 24 CSS pixels, assuming the CSS strut adds no greater extent. The parent's 14-CSS pixel allocation and the final 24-CSS pixel line describe different boxes.[ref]Visual formatting model details in CSS 2.2 by W3C. §10.8.1, inline-box height and independent contributions of child boxes
The
height property does not supply a preferred height for a non-replaced CSS inline box; height:40px on such a text element therefore does not replace this line-layout calculation. The properties determining a CSS preferred size have different applicability from line-height.[ref]CSS Box Sizing Module Level 3 by World Wide Web Consortium. §3.1.1, applicability of preferred width and height properties
CSS line box 2026-11-05
A CSS line box is the rectangular region containing the inline content of one line in a CSS inline formatting context. The browser fits successive inline content into lines, using line breaking when necessary, then uses CSS vertical alignment to determine each line's extent. A CSS inline box supplies one contribution to this enclosing region.[ref]
For ordinary baseline-aligned text, the CSS leading calculation supplies each contribution's height above and depth below the text baseline. Include the CSS strut among those contributions. Enclosing them requiresFor example, extents and CSS pixels produce a line of CSS pixels, although the individual extents sum to 14 and 20. The largest upper extent and largest lower extent can come from different contributions. The CSS leading diagram illustrates the same geometry with another pair of hypothetical metrics.
A CSS replaced element, such as an inline image, contributes according to its CSS margin box; it need not follow the text's line height. Other settings of CSS vertical alignment require additional positioning rules. These effects explain why a line's final height can exceed the
line-height declared on its surrounding CSS block container.[ref]Visual formatting model details in CSS 2.2 by W3C. §10.8, sizing and vertical alignment of inline-level boxes
CSS strut 2026-11-05
A CSS strut is the imaginary zero-width CSS inline box used to represent a CSS block container's own font and line height when a CSS line box is constructed. It supplies minimum extents on both sides of the text baseline, even when the actual text uses smaller metrics.[ref]
Visual formatting model details in CSS 2.2 by W3C. §10.8.1, imaginary strut and block-container line-height
Suppose the container has font ascent , font descent magnitude and line height CSS pixels. Its CSS leading is , so the strut contributes 14 above and 6 below the text baseline. A small text contribution with extents 7.5 above and 2.5 below still produces a line 20 CSS pixels high because the strut dominates both directions.
The minimum is geometric rather than merely a comparison of total heights. If another contribution extends 18 above and 2 below the same text baseline, the enclosing CSS line box becomes CSS pixels. Both the strut and the other contribution individually total 20. Keeping the separate upper and lower extents explains the extra height.
This construction concerns a CSS line box that participates in layout. CSS also specifies conditions under which empty line boxes are treated as nonexistent, so
line-height:20px alone does not make every otherwise empty block 20 CSS pixels high.[ref] Font line gap 2026-11-05
A font line gap is a font-wide metric giving an additional spacing allowance to combine with font ascent and font descent. For an elementary default line-spacing calculation using signed descent ,where is the ascent and the font line gap. OpenType's
sTypoLineGap is intended to be used with the matching sTypoAscender and sTypoDescender fields.[ref]OS/2 and Windows Metrics Table by Microsoft. sTypoLineGap and its relationship to the other typographic metrics
Suppose the chosen metrics are , and font units. The default spacing is 1100 font units. With 1000 font units per em at 18 pixels per em, that is 19.8 pixels between text baselines.
The stored font line gap provides an input to a spacing decision. An application can instead request a different line height, and CSS leading is then calculated from that requested height and the selected metrics. Nor does the font line gap measure the visible blank strip between every pair of lines: the ink bounding boxes vary with the particular glyphs. The line height diagram shows this distinction with schematic ink inside larger font-wide metric regions.
Leading (typography) 2026-11-05
Typographic leading concerns vertical spacing between lines of type. The term comes from the thin lead spacers used to separate lines of metal type. In current discussion, one must establish whether a quoted value means the complete spacing between text baselines or an additional allowance beyond the chosen font ascent and font descent.[ref]
A Glossary of Typographic Terms by Adobe. Entry leading: line spacing and the historical lead spacers
CSS leading uses the additional-allowance convention. If a single font contributes ascent and descent magnitude , and the chosen line height is , thenThe elementary inline-box construction allocates half of above the ascent and half below the descent. These quantities are font-wide metrics, rather than the actual ink bounding box of each glyph.[ref]
For hypothetical metrics , and CSS pixels, the extra leading is 4 CSS pixels, with 2 on each side. If the same metrics use , then : the allocated line region is smaller than the metric extent. Negative CSS leading is allowed, so visible ink can extend outside its line allocation. A line height value must consequently be interpreted together with the font and the layout convention.