Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

text-underline-offset — shifting an underline

The text-underline-offset property shifts an underline from its zero position without changing the text’s position.

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

Syntax

text-underline-offset: auto | <length-percentage>;

text-underline-offset shifts an existing underline; it does not create one. Enable it with text-decoration-line: underline. It does not shift overlines or line-throughs.

The initial auto lets the browser choose. Lengths and percentages may be negative: positive values move outward, negative values inward. text-underline-position defines the zero position; 0 is not auto.

The property inherits. Percentages use the used font-size and scale in descendants; lengths inherit as fixed computed values. A descendant cannot shift an underline originating on an ancestor.

The text-decoration shorthand neither includes nor resets this property.

Examples

<!doctype html>
<meta charset="utf-8">
<title>text-underline-offset</title>
<style>
  p {
    font: 32px/2 monospace;
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0;
  }
  .offset { text-underline-offset: 8px; }
</style>
<p>Underline sample</p>
<p class="offset">Underline sample</p>

Result

Two underlined lines reading "Underline sample". The second underline is positioned 8 CSS px farther outward than the first.

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