The text-underline-offset property controls how far an underline sits from text — useful for links, headings, and refined typography.
01
Offset
Move underline.
02
auto
Browser default.
03
Length
px, em, %.
04
Links
Better spacing.
05
Decoration
Needs underline.
06
Readability
Clear gaps.
Fundamentals
Introduction
The text-underline-offset property in CSS allows developers to control the position of the underline set by the text-decoration property.
This property is particularly useful when you want to adjust the space between the text and its underline, enhancing readability or achieving specific design effects.
Definition and Usage
Use text-underline-offset when a default underline feels too tight against letters — especially on links, underlined headings, or text with descenders like “g” and “y”.
💡
Beginner Tip
Always pair offset with an underline: text-decoration: underline; plus text-underline-offset: 4px; pushes the line farther below the text.
Foundation
📝 Syntax
The syntax for the text-underline-offset property is straightforward. It accepts length values, such as pixels (px), points (pt), or percentages (%).
syntax.css
element{text-underline-offset:length;}
Here, length is the distance by which the underline is offset from the default position of the text baseline.
The default value of text-underline-offset is auto, which means the browser determines the offset automatically based on font metrics and text decoration settings.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
auto
Push underline down
text-underline-offset: 4px;
Requires underline
text-decoration: underline;
Relative to font size
text-underline-offset: 0.15em;
Reset to browser default
text-underline-offset: auto;
Inherited
Yes
Reference
💎 Property Values
The text-underline-offset property accepts a keyword or length value.
Value
Example
Description
length
text-underline-offset: 5px;
Specifies the distance in pixels, points, or percentages by which the underline is offset from the text baseline.
auto
text-underline-offset: auto;
Automatically determines the offset based on font metrics and text decoration settings.
autopxem%
Context
When to Use text-underline-offset
text-underline-offset is helpful whenever underline spacing matters:
Navigation links — Add breathing room so underlines do not collide with descenders.
Headings — Create elegant underlined titles with extra gap below letters.
Custom link styles — Fine-tune offset alongside color and thickness.
Accessibility — Improve clarity when underline thickness is increased.
Preview
👀 Live Preview
Compare how different offset values change underline spacing on the same sentence:
auto Underlined text with browser default offset
2px Underlined text with browser default offset
6px Underlined text with browser default offset
10px Underlined text with browser default offset
Hands-On
Examples Gallery
In this example, we’ll adjust the underline offset for a paragraph of text.
📜 Basic Offset
Start with a simple underline and push it down with a length value.
Example 1 — Custom underline offset on a paragraph
In this example, we’ll adjust the underline offset for a paragraph of text.
index.html
<style>p{text-decoration:underline;text-underline-offset:5px;}</style><h1>Text with Custom Underline Offset</h1><p>This paragraph has a custom underline offset.</p>
Apply text-decoration: underline or text-decoration-line: underline.
Decoration
2
Offset value is set
Choose auto or a length like 4px or 0.15em.
Distance
3
Browser shifts the line
The underline moves down (positive) or up (negative) relative to its default position.
Render
=
✅
Refined typography
Underlined text looks cleaner with intentional spacing below the glyphs.
Compatibility
Browser Compatibility
The text-underline-offset property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it’s recommended to test your implementation across different browsers to ensure consistent behavior.
✓ Modern browsers · Widely supported
Fine-tuned underline spacing
Current Chrome, Firefox, Safari, Edge, and Opera support text-underline-offset with length and auto values.
96%Browser support
Google Chrome87+ · Desktop & Mobile
Full support
Mozilla Firefox70+ · Desktop & Mobile
Full support
Apple Safari12.1+ · macOS & iOS
Full support
Microsoft Edge87+ · All versions
Full support
Opera73+ · All versions
Full support
Testing tip
Verify offset appearance with different fonts and underline thickness values in target browsers.
text-underline-offset property96% supported
Bottom line:text-underline-offset is reliable for modern typography; test legacy browsers if you must support them.
Wrap Up
Conclusion
The text-underline-offset property provides developers with precise control over the position of underlines in text elements.
Whether you need to adjust spacing for better readability or achieve specific design effects, this property allows you to fine-tune the presentation of underlined text on your website.
Combine with text-decoration-color for branded links
❌ Don’t
Expect offset to work without text-decoration-line: underline
Use large negative offsets on paragraph text
Remove underlines from links and rely on color alone
Assume identical offset rendering across every typeface
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about text-underline-offset
Use these points when adjusting underline spacing in CSS.
5
Core concepts
↓01
Underline gap
Space below text.
Purpose
⚙02
auto
Default value.
Default
📏03
length
px, em, %.
Values
🔗04
underline
Required pair.
Rule
📝05
Inherited
Flows to children.
Cascade
❓ Frequently Asked Questions
text-underline-offset controls how far an underline sits from the text baseline. It works with underlines set by text-decoration or text-decoration-line.
The default is auto, which lets the browser choose the offset based on font metrics and decoration settings.
Yes. The property adjusts an existing underline. Apply text-decoration: underline or use text-decoration-line: underline first.
Yes. Negative length values move the underline closer to or through the text, though use them carefully for readability.
Yes, text-underline-offset is inherited. Setting it on a parent affects underlined text inside unless a child overrides it.