CSS text-underline-position Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The text-underline-position property controls where an underline sits relative to the text. Common values are auto (browser default) and under (clear of descenders and subscripts).

It is not part of the text-decoration shorthand and it inherits, so you can set under on :root for a whole page. You still need an underline from text-decoration-line.

Standard-track.

Baseline widely available for auto and under. Not deprecated as a property.

Limited support.

left and right (vertical writing modes) need Safari 18.2+. In horizontal text they behave like auto.

CSS Syntax

syntax.css
text-underline-position: auto | under | from-font | left | right | initial | inherit;

You can combine a vertical keyword with a horizontal one, for example under left.

Property Values

ValueDescriptionTry it
autoBrowser places the line at or under the alphabetic baseline (initial)Try it
underForces the line below the baseline, clear of descendersTry it
from-fontUses the font’s preferred underline position when availableTry it
leftIn vertical writing modes, line on the left; otherwise like autoTry it
initialResets to autoTry it
inheritTakes the parent’s positionTry it

How to Use text-underline-position

Draw an underline first, then choose where it sits. Position alone never creates a line.

  1. Set text-decoration-line: underline.
  2. Pick auto, under, or from-font for horizontal text.
  3. Use left / right only with a vertical writing-mode.
  4. Fine-tune distance with text-underline-offset after position is set.
GoalTypical value
Default lookauto
Clear subscripts / descendersunder
Honor font metricsfrom-font
Vertical text sideleft or right

Live Preview

Same underlined phrase with a subscript. Change only text-underline-position.

Watch how the line clears (or crosses) the subscript. left / right need vertical writing mode—see Example 3.

Text

H2O sample underline

text-underline-position: under

CSS Examples

Each snippet focuses on text-underline-position. Use Try It Yourself for a live editor.

Example 1 — Clear Descenders with under

Keep the underline below subscripts and descenders.

CSS
<style>
  p {
    text-decoration-line: underline;
    text-underline-position: under;
  }
</style>

<p>H<sub>2</sub>O sample underline</p>
Try It Yourself

How It Works

  1. Draw the line. text-decoration-line: underline creates the decoration.
  2. Force below. under places it under the alphabetic baseline.
  3. Clear glyphs. Subscripts and descenders (g, y, p) stay readable.
  4. Global tip. Because it inherits, :root { text-underline-position: under; } can set a page default.

Example 2 — Browser Default with auto

Let the user agent choose the underline position.

CSS
<style>
  p {
    text-decoration-line: underline;
    text-underline-position: auto;
  }
</style>

<p>H<sub>2</sub>O sample underline</p>
Try It Yourself

How It Works

  1. Keep the underline. Position needs a line to place.
  2. Use auto. The browser picks at or under the alphabetic baseline.
  3. May cross subscripts. Compare with Example 1 to see why under exists.
  4. Reset tip. initial also returns to auto.

Example 3 — left in Vertical Text

Place the underline on the left side when writing mode is vertical.

CSS
<style>
  p {
    writing-mode: vertical-rl;
    text-decoration-line: underline;
    text-underline-position: left;
  }
</style>

<p>Sample underline</p>
Try It Yourself

How It Works

  1. Go vertical. writing-mode: vertical-rl makes left/right meaningful.
  2. Underline the text. Same line longhand as before.
  3. Pick a side. left puts the decoration on the left of the vertical line of text.
  4. Horizontal note. In horizontal mode, left / right act like auto.

Edge Cases & Pitfalls

If the underline sits in the wrong place, one of these is usually why.

line

No underline means no visible position

text-underline-position only places underlines. Without text-decoration-line: underline, nothing changes.

offset

Position vs offset

Position chooses the starting rule (auto / under / …). text-underline-offset then shifts the line from that point.

shorthand

Not reset by text-decoration

Hover rules that set text-decoration: underline will not wipe your position. Useful for page-wide under defaults.

vertical

left / right need vertical mode

In horizontal writing modes they match auto. Safari support for these keywords is newer (18.2+).

from-font

from-font falls back to auto

If the font has no underline metrics, the browser behaves as if auto was set. Do not rely on a visible difference for every typeface.

Browser Support

text-underline-position is a browser CSS property for underline placement. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since Jul 2020

text-underline-position

auto / under: Chrome 33+, Firefox 74+, Safari 12.1+, Edge 12+. from-font: Chrome 87+, Firefox 74+, Safari 12.1+. left / right: Chrome 71+, Firefox 74+, Safari 18.2+.

97% auto / under support
Google Chrome 33+ (under)
Full support
Mozilla Firefox 74+
Full support
Apple Safari 12.1+
Full support
Microsoft Edge 12+
Full support
Opera 20+
Full support
Samsung Internet 4+
Full support
Internet Explorer No
Not supported
text-underline-position Widely supported

Bottom line: Safe for auto and under in modern browsers. Treat left / right as progressive enhancement until Safari 18.2+ is acceptable.

Key Takeaways

  • Role: chooses where the underline sits relative to the text.
  • Common values: auto and under. Initial is auto.
  • Inherited: yes, and not reset by the text-decoration shorthand.
  • Tip: use under for formulas; use offset to nudge distance afterward.

One line: underline first, then set text-underline-position when the default line crosses descenders or subscripts.

Frequently Asked Questions

It chooses where an underline is drawn: at the alphabetic baseline (auto), clear of descenders (under), from font metrics (from-font), or left/right in vertical writing modes.
auto. The browser places the underline at or under the alphabetic baseline using its own rules.
Yes. Set text-decoration-line: underline (or text-decoration: underline). Position alone does not draw a line.
Use under when underlines must clear descenders and subscripts, such as chemical formulas or math with <sub>.
No. It inherits and is not reset by text-decoration, so you can set under on :root for a whole document.
Baseline widely available for auto and under (Chrome 33+, Firefox 74+, Safari 12.1+, Edge 12+). left and right need Safari 18.2+. It is a browser CSS property, not a Node.js feature.

Next: top

Learn how the CSS top property offsets positioned elements.

top tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful