CKTIS / CSS
text-underline-position — underline placement
The text-underline-position property controls an underline’s placement relative to text. It supports automatic positioning, font metrics, and side selection in vertical typesetting.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
text-underline-position: auto | [ from-font | under ] || [ left | right ];text-underline-position positions an underline but does not enable it: use text-decoration: underline. Its initial value is auto; the property is inherited and is not reset by the text-decoration shorthand.
auto leaves placement to the browser. from-font uses suitable metrics from the first available font, falling back to auto when absent. under places the line underneath the text, usually below descenders, but does not guarantee collision-free placement.
left and right select a side in vertical typesetting; in horizontal typesetting they are treated as auto. Either can accompany under or from-font, for example under right. The || notation means one or both groups in either order; auto stands alone.
The property controls decorations originating on the element, not decorations from its ancestors. It also establishes the zero position for text-underline-offset, which provides further displacement.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Underline position</title>
<style>
p { font: 32px/1.8 sans-serif; text-decoration: underline; }
.auto { text-underline-position: auto; }
.under { text-underline-position: under; }
</style>
<p class="auto">auto: gypq</p>
<p class="under">under: gypq</p>
</html>Result
Two underlined lines: "auto: gypq" and "under: gypq". The second uses under positioning; exact pixel positions depend on the font and browser.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.