CSS text-decoration-line Property
The CSS text-decoration-line property specifies which decorative lines appear on text, including underlines, overlines, and strikethroughs.
It accepts one or more decoration-line keywords, allowing multiple line types to be applied simultaneously. The property controls which lines appear, while related properties determine their color, style, thickness, and positioning.
The text-decoration-line property is part of the text-decoration shorthand and is commonly used for links, headings, deleted content, and decorative text effects.
text-decoration-line Syntax
The text-decoration-line property accepts none or one or more decoration-line keywords.
Basic Syntax
p {
text-decoration-line: underline;
}
This adds an underline beneath the paragraph text.
Available Values
.example {
text-decoration-line: none;
}
.example {
text-decoration-line: underline;
}
.example {
text-decoration-line: overline;
}
.example {
text-decoration-line: line-through;
}
.example {
text-decoration-line: blink;
}
Combining Multiple Values
.example {
text-decoration-line: underline overline;
}
.example {
text-decoration-line: underline line-through;
}
.example {
text-decoration-line: underline overline line-through;
}
Multiple decoration-line keywords are separated by spaces. Each line type can appear only once in a declaration.
CSS-Wide Keywords
.example {
text-decoration-line: initial;
}
.example {
text-decoration-line: inherit;
}
.example {
text-decoration-line: unset;
}
.example {
text-decoration-line: revert;
}
.example {
text-decoration-line: revert-layer;
}
The initial value is none, meaning the element does not introduce a text decoration.
Property Values
The property accepts five decoration-line keywords, although blink is retained only for compatibility.
| Value | Description |
|---|---|
none |
Specifies no text decoration line. This is the initial value. |
underline |
Draws a line beneath the text, according to the writing mode and underline positioning rules. |
overline |
Draws a line over the text. |
line-through |
Draws a line through the text. |
blink |
Legacy keyword that does not cause blinking in modern browsers. |
| Multiple keywords | Combines two or more different decoration-line types in one declaration. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | none |
| Inherited | No |
| Applies to | All elements |
| Computed value | Specified decoration-line keywords |
| Animation type | Discrete |
| Percentages | Not applicable |
| Initial decoration style | solid |
| Initial decoration color | currentColor |
| Specification | CSS Text Decoration Module Level 3 |
Valid Examples
.example {
text-decoration-line: none;
}
.example {
text-decoration-line: underline;
}
.example {
text-decoration-line: overline;
}
.example {
text-decoration-line: line-through;
}
.example {
text-decoration-line: underline overline;
}
.example {
text-decoration-line: underline line-through;
}
.example {
text-decoration-line: overline line-through;
}
.example {
text-decoration-line: underline overline line-through;
}
Invalid Examples
.example {
text-decoration-line: under;
}
.example {
text-decoration-line: strike;
}
.example {
text-decoration-line: none underline;
}
.example {
text-decoration-line: underline underline;
}
.example {
text-decoration-line: underline dotted;
}
.example {
text-decoration-line: red;
}
The property accepts decoration-line keywords only. Color, style, and thickness values belong to other properties or the text-decoration shorthand.
How It Works
The text-decoration-line property determines which decorative lines the browser draws in relation to text.
Step 1: Create the Text
<p class="decorated-text">Learn CSS Typography</p>
Step 2: Add an Underline
.decorated-text {
text-decoration-line: underline;
}
The browser draws a line beneath the text.
Step 3: Change the Decoration Type
.decorated-text {
text-decoration-line: overline;
}
The underline is replaced with an overline.
Step 4: Combine Decoration Types
.decorated-text {
text-decoration-line: underline overline;
}
The browser draws both an underline and an overline.
Step 5: Customize the Appearance
.decorated-text {
text-decoration-line: underline overline;
text-decoration-style: solid;
text-decoration-color: #2563eb;
text-decoration-thickness: 2px;
}
Both lines use the specified blue color and thickness.
Important Consideration
Text decorations are painted as part of text rendering. They do not normally change the dimensions of the element's layout box or increase line spacing.
The none Value
The none keyword specifies that the element does not introduce a text decoration line.
Basic Example
.example {
text-decoration-line: none;
}
Removing a Link's Default Underline
a {
text-decoration-line: none;
}
This removes the underline normally applied to links by browser styles, provided no other applicable decoration overrides it.
Restoring the Underline
a {
text-decoration-line: none;
}
a:hover,
a:focus-visible {
text-decoration-line: underline;
}
The underline appears when the link is hovered or receives keyboard focus.
Using none With Other Values
.example {
text-decoration-line: none underline;
}
This declaration is invalid. The none keyword cannot be combined with another decoration-line keyword.
Important Consideration
Setting text-decoration-line: none on a descendant does not necessarily remove a decoration introduced by an ancestor. Decoration propagation is separate from CSS inheritance.
The underline Value
The underline keyword draws a decorative line beneath text according to its writing mode and underline positioning rules.
Basic Underline
.example {
text-decoration-line: underline;
}
Colored Underline
.example {
text-decoration-line: underline;
text-decoration-color: #2563eb;
}
Thick Underline
.example {
text-decoration-line: underline;
text-decoration-thickness: 3px;
}
Wavy Underline
.example {
text-decoration-line: underline;
text-decoration-style: wavy;
}
Adjusting Underline Offset
.example {
text-decoration-line: underline;
text-underline-offset: 4px;
}
The underline is moved away from its normal position.
Common Uses
Underlines are frequently used to identify hyperlinks, emphasize text, and create decorative heading treatments.
Important Consideration
Underlines are strongly associated with links. Avoid using them extensively on noninteractive text when doing so could confuse readers.
The overline Value
The overline keyword draws a decorative line over the text.
Basic Overline
.example {
text-decoration-line: overline;
}
Colored Overline
.example {
text-decoration-line: overline;
text-decoration-color: #059669;
}
Double Overline
.example {
text-decoration-line: overline;
text-decoration-style: double;
}
Thick Overline
.example {
text-decoration-line: overline;
text-decoration-thickness: 3px;
}
Combining With Underline
.example {
text-decoration-line: overline underline;
}
Creates decorative lines above and below the text.
Common Uses
Overlines are less common than underlines but can be useful for headings, mathematical notation, and decorative typography.
Important Consideration
The exact position of an overline depends on font metrics, writing mode, and browser rendering.
The line-through Value
The line-through keyword draws a line through the text.
Basic Strikethrough
.example {
text-decoration-line: line-through;
}
Colored Strikethrough
.example {
text-decoration-line: line-through;
text-decoration-color: #dc2626;
}
Thick Strikethrough
.example {
text-decoration-line: line-through;
text-decoration-thickness: 2px;
}
Old Price Example
<p>Price: <del class="old-price">$49</del> $39</p>
.old-price {
text-decoration-line: line-through;
text-decoration-color: #dc2626;
}
The <del> element communicates deleted content semantically, while CSS controls its visual appearance.
Completed Task Example
.completed-task {
color: #64748b;
text-decoration-line: line-through;
}
This visually distinguishes completed tasks from unfinished tasks.
Important Consideration
A strikethrough does not automatically communicate deletion or completion to assistive technology. Use appropriate HTML semantics and accessible text when the meaning matters.
The blink Value
The blink keyword is a legacy decoration-line value retained for compatibility with older CSS content.
Legacy Syntax
.example {
text-decoration-line: blink;
}
Modern browsers do not make text blink when this value is specified.
Combining With Another Line
.example {
text-decoration-line: underline blink;
}
The underline remains the meaningful visible decoration. The blink keyword does not add a blinking effect.
Why Blinking Text Is Discouraged
Flashing or blinking content can distract readers and create accessibility problems, particularly for users sensitive to visual motion.
Recommended Alternative
Use readable, persistent visual emphasis such as an underline, font weight, border, or background color rather than blinking text.
Important Consideration
Do not rely on blink for an interactive state, notification, or other important information.
Multiple Decoration Lines
The text-decoration-line property can apply more than one decoration-line type simultaneously.
Underline and Overline
.example {
text-decoration-line: underline overline;
}
Draws lines above and below the text.
Underline and Strikethrough
.example {
text-decoration-line: underline line-through;
}
Draws an underline and a line through the text.
Overline and Strikethrough
.example {
text-decoration-line: overline line-through;
}
Draws an overline and a strikethrough.
All Three Lines
.example {
text-decoration-line: underline overline line-through;
}
Draws all three decoration-line types.
Shared Color and Style
.example {
text-decoration-line: underline overline;
text-decoration-style: double;
text-decoration-color: #2563eb;
text-decoration-thickness: 2px;
}
Both decorations use the same blue color, double style, and thickness.
Keyword Order
.example {
text-decoration-line: underline overline;
}
.example {
text-decoration-line: overline underline;
}
These declarations specify the same two decoration-line types. Their order does not change the visual result.
Important Consideration
Each decoration-line keyword can appear only once, and none cannot be combined with another line type.
Decoration Propagation
Text decorations behave differently from inherited CSS properties. Although text-decoration-line is not inherited, decorations introduced by an ancestor can propagate visually across descendant text.
Parent Decoration
<p class="parent-decoration">
Parent text with <span>child text</span>.
</p>
.parent-decoration {
text-decoration-line: underline;
}
The underline can continue across the descendant text.
Setting none on a Descendant
.parent-decoration {
text-decoration-line: underline;
}
.parent-decoration span {
text-decoration-line: none;
}
The descendant's none value does not remove the underline introduced by the parent.
Adding a Descendant Decoration
.parent-decoration {
text-decoration-line: underline;
}
.parent-decoration span {
text-decoration-line: overline;
}
The descendant introduces its own overline while the parent's underline can continue across its text.
Different Decoration Colors
.parent-decoration {
text-decoration-line: underline;
text-decoration-color: blue;
}
.parent-decoration span {
text-decoration-line: overline;
text-decoration-color: red;
}
The parent's underline and the descendant's overline can use different colors because they originate from different elements.
Important Consideration
Decoration propagation depends on the formatting structure. Certain elements, including atomic inline-level elements such as inline blocks, do not receive propagated decorations in the same way as ordinary inline text.
Related Properties
Several CSS properties work with text-decoration-line to customize the appearance and positioning of text decorations.
| Property | Purpose |
|---|---|
text-decoration |
Shorthand for decoration line, style, color, and thickness. |
text-decoration-color |
Controls the decoration color. |
text-decoration-style |
Controls whether the decoration is solid, double, dotted, dashed, or wavy. |
text-decoration-thickness |
Controls the thickness of decoration lines. |
text-decoration-skip-ink |
Controls whether decoration lines skip portions of glyph ink. |
text-underline-offset |
Adjusts the position of an underline relative to its normal location. |
text-underline-position |
Controls underline positioning. |
Changing the Decoration Color
.example {
text-decoration-line: underline;
text-decoration-color: #2563eb;
}
Changing the Decoration Style
.example {
text-decoration-line: underline;
text-decoration-style: wavy;
}
Changing the Decoration Thickness
.example {
text-decoration-line: underline;
text-decoration-thickness: 3px;
}
Adjusting Underline Position
.example {
text-decoration-line: underline;
text-underline-offset: 4px;
}
Combining Related Properties
.example {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: #2563eb;
text-decoration-thickness: 2px;
text-underline-offset: 3px;
}
This creates a blue underline with a custom thickness and offset.
Relationship With text-decoration
The text-decoration-line property is one of four longhand components included in the text-decoration shorthand.
Longhand Version
.example {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: #2563eb;
text-decoration-thickness: 2px;
}
Equivalent Shorthand
.example {
text-decoration: underline wavy #2563eb 2px;
}
Shorthand With Multiple Lines
.example {
text-decoration: underline overline solid #2563eb 2px;
}
Both lines share the specified color, style, and thickness.
Shorthand Reset Behavior
.example {
text-decoration-line: underline overline;
text-decoration: underline;
}
The final shorthand replaces the earlier line selection with underline and resets the other longhand components to their initial values.
Preserving a Custom Line Selection
.example {
text-decoration: underline solid #2563eb 2px;
text-decoration-line: underline overline;
}
The final longhand changes the selected lines without resetting the color, style, or thickness.
Important Consideration
When declarations have the same cascade priority, a later shorthand overrides earlier longhand values for all components included in that shorthand.
Practical Examples
Standard Link Underline
a {
text-decoration-line: underline;
}
Preserves a familiar visual indicator for hyperlinks.
Custom Link Underline
.custom-link {
color: #1d4ed8;
text-decoration-line: underline;
text-decoration-color: currentColor;
text-decoration-thickness: 2px;
text-underline-offset: 3px;
}
Creates a clearly visible underline that follows the link's text color.
Decorative Heading
.decorated-heading {
text-decoration-line: underline overline;
text-decoration-color: #2563eb;
text-decoration-thickness: 2px;
}
Adds lines above and below a heading.
Deleted Text
<p>The <del>old wording</del> has been replaced.</p>
del {
text-decoration-line: line-through;
text-decoration-color: #dc2626;
}
Uses semantic HTML to identify deleted text and CSS to style its decoration.
Completed Task
.completed-task {
color: #64748b;
text-decoration-line: line-through;
}
Visually identifies a completed task.
Wavy Underline
.annotation {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: #dc2626;
}
Creates a red wavy underline for an annotation or warning.
Double Overline
.overlined-heading {
text-decoration-line: overline;
text-decoration-style: double;
text-decoration-color: #7c3aed;
}
Creates two parallel lines above the text.
Hover Underline
.hover-link {
text-decoration-line: none;
}
.hover-link:hover,
.hover-link:focus-visible {
text-decoration-line: underline;
}
Adds an underline during hover or keyboard focus. Ensure links remain recognizable before interaction.
Underline and Strikethrough
.combined-decoration {
text-decoration-line: underline line-through;
text-decoration-color: #2563eb;
}
Applies two decoration-line types simultaneously.
Responsive Heading Decoration
.responsive-heading {
font-size: 24px;
text-decoration-line: underline;
text-decoration-thickness: 0.1em;
}
@media (min-width: 768px) {
.responsive-heading {
font-size: 36px;
}
}
The relative decoration thickness scales with the font size.
text-decoration-line Example
This example compares the main decoration-line values and demonstrates how multiple lines can be combined.
HTML Example
<div class="decoration-line-demo">
<p class="line-none">No Decoration</p>
<p class="line-underline">Underline</p>
<p class="line-overline">Overline</p>
<p class="line-through">Line Through</p>
<p class="line-under-over">Underline and Overline</p>
<p class="line-under-through">Underline and Line Through</p>
<p class="line-all">All Three Lines</p>
</div>
CSS Example
.decoration-line-demo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 12px;
}
.decoration-line-demo p {
margin: 0;
padding: 16px;
border: 1px solid #cbd5e1;
background: #f8fafc;
color: #1f2937;
font-size: 18px;
line-height: 1.6;
text-align: center;
text-decoration-style: solid;
text-decoration-color: #2563eb;
text-decoration-thickness: 2px;
}
.decoration-line-demo .line-none {
text-decoration-line: none;
}
.decoration-line-demo .line-underline {
text-decoration-line: underline;
}
.decoration-line-demo .line-overline {
text-decoration-line: overline;
}
.decoration-line-demo .line-through {
text-decoration-line: line-through;
}
.decoration-line-demo .line-under-over {
text-decoration-line: underline overline;
}
.decoration-line-demo .line-under-through {
text-decoration-line: underline line-through;
}
.decoration-line-demo .line-all {
text-decoration-line: underline overline line-through;
}
No Decoration
Underline
Overline
Line Through
Underline and Overline
Underline and Line Through
All Three Lines
All samples use the same text color, decoration color, style, and thickness. Only the text-decoration-line value changes.
Comparing the Results
| Sample | Decoration |
|---|---|
| No Decoration | No decorative line |
| Underline | Line beneath the text |
| Overline | Line above the text |
| Line Through | Line through the text |
| Underline and Overline | Lines above and below the text |
| Underline and Line Through | Underline and strikethrough |
| All Three Lines | Underline, overline, and strikethrough |
Changing the Decoration Color
.decoration-line-demo p {
text-decoration-color: #dc2626;
}
All visible decoration lines become red.
Changing the Decoration Style
.decoration-line-demo p {
text-decoration-style: wavy;
}
All visible decoration lines use a wavy appearance.
Changing the Decoration Thickness
.decoration-line-demo p {
text-decoration-thickness: 4px;
}
All visible decoration lines become thicker.
Removing the Decorations
.decoration-line-demo p {
text-decoration-line: none;
}
To remove every sample's decoration, replace the individual line-selection rules or override them with a declaration that wins in the cascade.
Accessibility Considerations
Text decoration lines can help communicate meaning, but they should be used consistently and supported by appropriate HTML semantics.
Keep Links Recognizable
Underlines are a familiar visual indicator for links. Removing them can make links harder to distinguish from surrounding text.
Do Not Rely on Decoration Alone
A strikethrough or overline may not communicate its intended meaning to assistive technology. Use semantic HTML and descriptive text when meaning matters.
Use Semantic HTML for Deleted Content
<p>The <del>previous version</del> has been replaced.</p>
The <del> element identifies deleted content semantically.
Maintain Keyboard Focus Indicators
When links gain an underline on hover, provide an appropriate keyboard focus state using :focus-visible.
Avoid Excessive Decorations
Multiple decoration lines can make text harder to read, particularly at small font sizes.
Maintain Sufficient Contrast
Decoration lines should remain visible against their background. Avoid very pale colors or excessively thin lines.
Avoid Blinking Effects
The legacy blink keyword should not be used as a visual communication technique.
Support Text Resizing
Test decorations at increased browser zoom and larger font sizes to ensure they do not obscure the text.
Use Consistent Meaning
Use underlines, overlines, and strikethroughs consistently so readers can understand their intended purpose.
Common Mistakes
Using an Invalid Keyword
.example {
text-decoration-line: strike;
}
Use line-through instead of strike.
Combining none With Another Value
.example {
text-decoration-line: none underline;
}
The none keyword must be used by itself.
Repeating a Decoration Keyword
.example {
text-decoration-line: underline underline;
}
Each decoration-line keyword can appear only once in a declaration.
Using a Style Keyword
.example {
text-decoration-line: dotted;
}
Use text-decoration-style to control the appearance of the line.
Using a Color Value
.example {
text-decoration-line: red;
}
Use text-decoration-color to control the line color.
Using a Thickness Value
.example {
text-decoration-line: 3px;
}
Use text-decoration-thickness to control the line thickness.
Assuming the Property Is Inherited
The property is not inherited, even though decorations can propagate visually across descendant text.
Trying to Remove a Parent's Decoration
.parent {
text-decoration-line: underline;
}
.parent span {
text-decoration-line: none;
}
The descendant's none value does not remove the underline introduced by the parent.
Overwriting Longhand Values With the Shorthand
.example {
text-decoration-line: underline overline;
text-decoration: underline;
}
The final shorthand replaces the earlier line selection.
Expecting Decoration Lines to Change Layout Height
Text decorations are painted around text and do not normally increase line-box height.
Using Strikethrough Without Semantic Meaning
Use appropriate HTML semantics when text represents deleted or changed information.
Removing Link Underlines Without an Alternative
Links may become difficult to recognize when their underlines are removed.
Relying on blink
Modern browsers do not make text blink when blink is specified.
Important Considerations
Keep the following points in mind when using text-decoration-line:
- It determines which decorative lines appear on text.
- The initial value is
none. - The property is not inherited.
- Decorations introduced by ancestors can propagate visually to descendant text.
- The
nonekeyword specifies no decoration line. - The
underlinekeyword draws a line beneath text. - The
overlinekeyword draws a line above text. - The
line-throughkeyword draws a line through text. - The legacy
blinkkeyword does not produce blinking in modern browsers. - Multiple decoration-line keywords can be combined.
- The
nonekeyword cannot be combined with other line keywords. - Each decoration-line keyword can appear only once in a declaration.
- Keyword order does not change which decoration lines are drawn.
- Decoration lines share the style, color, and thickness introduced by the same element.
- The property does not control decoration color.
- The property does not control decoration style.
- The property does not control decoration thickness.
- Use related longhand properties for additional customization.
- The property is included in the
text-decorationshorthand. - A later shorthand can reset the decoration-line selection.
- Declaration order matters when combining shorthand and longhand properties.
- Decorations do not normally change layout dimensions.
- Decoration positions can vary by font, writing mode, and browser.
- Underlines are commonly associated with hyperlinks.
- Overlines are useful for selected typographic and mathematical presentations.
- Strikethroughs are commonly used for deleted or completed content.
- Use semantic HTML when decoration lines communicate meaning.
- Do not rely on visual decorations alone for important information.
- Preserve recognizable link and keyboard focus indicators.
- Test decorations at different font sizes and zoom levels.
Browser Support
The CSS text-decoration-line property is widely available across modern browsers, including Chrome, Edge, Firefox, and Safari.
Basic underline, overline, and line-through decorations are well established. The legacy blink keyword does not create blinking text in modern browsers.
For current compatibility information, visit Can I Use? and search for text-decoration-line.
Basic Compatibility
.example {
text-decoration-line: underline;
}
Basic underlines are supported across modern browsers.
Multiple Decoration Lines
.example {
text-decoration-line: underline overline;
}
Modern browsers support multiple decoration-line keywords in one declaration.
Feature Detection
@supports (text-decoration-line: underline overline) {
.example {
text-decoration-line: underline overline;
}
}
This feature query checks whether the browser recognizes the combined decoration-line declaration.
Fallback Example
.example {
text-decoration: underline;
text-decoration-line: underline overline;
}
The first declaration provides a basic underline for older implementations that do not recognize the later longhand declaration.
Testing Recommendations
Test decoration-line combinations with different fonts, writing modes, and text sizes. Verify that decorations remain visible and do not obscure characters.
Specifications
The text-decoration-line property is defined in the CSS Text Decoration Module Level 3 specification.
CSS Text Decoration Module Level 3 - text-decoration-line Property
The specification defines the supported decoration-line keywords, combinations, and text decoration behavior.
For additional documentation and examples, consult MDN Web Docs.
