Example 1 — Push the Underline Down
Underline the text, then add a fixed gap.
<style>
p {
text-decoration-line: underline;
text-underline-offset: 8px;
}
</style>
<p>Sample underline offset</p> How It Works
- Draw the line.
text-decoration-line: underlinecreates the decoration. - Set the offset.
8pxmoves that underline farther from the glyphs. - Shorthand-safe. Changing
text-decorationlater will not clear this offset. - Why use it. Gives breathing room so descenders (g, y, p) do not collide with the line.

