CSS text-underline-position Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Typography

What You’ll Learn

The text-underline-position property controls where underlines are drawn — below text in horizontal layouts or beside text in vertical writing modes.

01

Placement

Where line sits.

02

auto

Browser picks.

03

under

Below text.

04

left / right

Vertical text.

05

Decoration

Needs underline.

06

Typography

Fine control.

Introduction

The text-underline-position property in CSS allows web developers to control the position of underlines for text.

This property is particularly useful for fine-tuning the appearance of underlined text, especially in different writing modes and scripts. It can enhance readability and aesthetics by allowing more precise control over underline placement.

Definition and Usage

Use text-underline-position when default underlines collide with descenders (like “g” and “y”) or when vertical text needs the line on a specific side of the characters.

💡
Beginner Tip

For horizontal text, text-underline-position: under; with text-decoration: underline; keeps the line fully below the glyphs instead of crossing descenders.

📝 Syntax

The syntax for the text-underline-position property is straightforward. It can be applied to any element containing text.

syntax.css
element {
  text-underline-position: value;
}

Here, value can be one of several keywords that define the position of the underline.

Basic Example

text-underline-position.css
p {
  text-underline-position: under;
  text-decoration: underline;
}

Syntax Rules

  • Keyword values include auto, under, left, right, and under left.
  • left and right apply mainly in vertical writing modes.
  • under left combines placement for vertical text layouts.
  • Requires an underline from text-decoration or text-decoration-line.
  • The property is inherited.

Related Properties

  • text-underline-offset — adjusts distance between text and underline
  • text-decoration — shorthand for underline and other lines
  • writing-mode — sets horizontal or vertical text flow
  • text-decoration-thickness — controls underline stroke width

🎯 Default Value

The default value of the text-underline-position property is auto, which lets the browser decide the most appropriate position for the underline based on the font and text.

⚡ Quick Reference

QuestionAnswer
Default valueauto
Underline below texttext-underline-position: under;
Vertical text, line on lefttext-underline-position: left;
Requires underlinetext-decoration: underline;
Pair with spacingtext-underline-offset
InheritedYes

💎 Property Values

The text-underline-position property accepts keyword values that define underline placement.

ValueExampleDescription
autotext-underline-position: auto;The browser chooses the underline position based on the font and the text’s language.
undertext-underline-position: under;The underline is placed below the text.
lefttext-underline-position: left;The underline is placed to the left of the text. This is used for vertical writing modes.
righttext-underline-position: right;The underline is placed to the right of the text. This is used for vertical writing modes.
under lefttext-underline-position: under left;For vertical text, the underline is below the text and to the left.
auto under left right under left

When to Use text-underline-position

text-underline-position is the right choice when underline placement affects clarity:

  • Links with descenders — Use under so lines do not cut through letters like “g”.
  • Vertical layouts — Place underlines on left or right in vertical writing modes.
  • Multilingual sites — Let auto respect language-specific typography when appropriate.
  • Design systems — Standardize underline behavior alongside offset and thickness.

👀 Live Preview

Compare auto and under on text with descenders, plus vertical text with left:

auto Typography with jumping glyphs and descenders
under Typography with jumping glyphs and descenders
縦書きテキスト

Examples Gallery

In this example, we’ll change the underline position of some text to be below the text.

📜 Horizontal Text

Place underlines below text and compare with the browser default.

Example 1 — Underline positioned under the text

In this example, we’ll change the underline position of some text to be below the text.

index.html
<style>
  p {
    text-underline-position: under;
    text-decoration: underline;
  }
</style>

<h1>Text with Custom Underline Position</h1>
<p>This is a paragraph with the underline positioned under the text.</p>
Try It Yourself

How It Works

The underline is forced below the full text box, avoiding overlap with descenders on letters like “g” and “y”.

Example 2 — auto vs under comparison

See how the browser default differs from explicitly placing the line under the text.

compare.css
.auto-line {
  text-decoration: underline;
  text-underline-position: auto;
}

.under-line {
  text-decoration: underline;
  text-underline-position: under;
}
Try It Yourself

How It Works

auto may use font-specific placement; under consistently draws the line beneath the entire line box.

📄 Vertical Writing

Control underline side placement when text flows vertically.

Example 3 — Underline on the left in vertical text

Combine writing-mode: vertical-rl with text-underline-position: left for vertical layouts.

vertical.css
.vertical {
  writing-mode: vertical-rl;
  text-decoration: underline;
  text-underline-position: left;
}
Try It Yourself

How It Works

In vertical writing modes, left and right refer to sides of the text column rather than above or below.

♿ Accessibility

  • Keep links identifiable — Position adjusts placement; do not remove underlines from links without another clear indicator.
  • Improve readabilityunder can help when thick underlines overlap letter shapes.
  • Test with real content — Verify descenders and multilingual text in your chosen typeface.
  • Combine with contrast — Use sufficient color contrast for underlines and link text.

position vs offset

text-underline-position chooses where the line is drawn (below, left, right). text-underline-offset moves it farther by a specific distance. Use both for precise control.

position-offset.css
a {
  text-decoration-line: underline;
  text-underline-position: under;
  text-underline-offset: 4px;
}

🧠 How text-underline-position Works

1

Underline is enabled

Apply text-decoration: underline on the text element.

Decoration
2

Position keyword is set

Choose auto, under, left, or right.

Placement
3

Browser draws the line

The underline appears on the chosen side relative to the text flow and writing mode.

Render
=

Cleaner underlines

Text looks more polished with intentional underline placement.

Browser Compatibility

The text-underline-position property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

Modern browsers · Widely supported

Precise underline placement

Current Chrome, Firefox, Safari, Edge, and Opera support auto, under, and vertical-mode keywords.

95% Browser support
Google Chrome 33+ · Desktop & Mobile
Full support
Mozilla Firefox 52+ · Desktop & Mobile
Full support
Apple Safari 12.1+ · macOS & iOS
Full support
Microsoft Edge 79+ · All versions
Full support
Opera 20+ · All versions
Full support

Testing tip

Vertical keywords like left and under left are most relevant with writing-mode: vertical-rl or vertical-lr.

text-underline-position property 95% supported

Bottom line: text-underline-position: under; is widely supported for horizontal typography in modern browsers.

Conclusion

The text-underline-position property is a valuable tool for web developers looking to refine the presentation of underlined text.

By customizing the position of underlines, you can enhance the readability and visual appeal of your text, especially in complex layouts and designs. Experiment with different values to see how this property can improve the typography on your web pages.

💡 Best Practices

✅ Do

  • Use under for links when descenders look crowded
  • Pair with text-underline-offset for extra spacing
  • Test vertical keywords with writing-mode when needed
  • Keep auto for multilingual content when font hints help
  • Combine with text-decoration-thickness for design systems

❌ Don’t

  • Expect position to work without an underline enabled
  • Confuse text-underline-position with text-underline-offset
  • Assume identical rendering for every font and language
  • Remove link underlines and rely on color alone

Key Takeaways

Knowledge Unlocked

Five things to remember about text-underline-position

Use these points when controlling underline placement in CSS.

5
Core concepts
02

auto

Default value.

Default
03

under

Below text.

Common
04

left / right

Vertical modes.

Advanced
🔗 05

Inherited

Flows to children.

Cascade

❓ Frequently Asked Questions

text-underline-position controls where an underline is drawn relative to the text, such as below the text or beside it in vertical writing modes.
The default is auto, which lets the browser choose the best underline position based on the font and language.
Yes. The property adjusts underline placement. Apply text-decoration: underline or text-decoration-line: underline first.
under forces the underline below the text. auto uses font and language hints, which may skip descenders on some typefaces.
Yes, text-underline-position is inherited. Child elements follow the parent setting unless overridden.

Practice in the Live Editor

Open the HTML editor and compare auto vs under on underlined link text.

HTML Editor →

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.

5 people found this page helpful