Definition and Usage
The text-decoration-line
property specifies the types of line decorations applied to text.
Basic Example
The text-decoration-line value is underline.
Formal syntax
selector {
text-decoration-line: none | [ underline || overline || line-through || blink ]
}
Values
The text-decoration-line
property determines which line decorations, if any, are applied to the text. The following values define how those decorations appear:
none |
No text decoration is applied. |
---|---|
underline |
Each line of text is underlined. |
overline |
Each line of text has a line above it. |
line-through |
Each line of text is struck through. |
blink |
The text blinks. Browser support is limited, and usage is discouraged.
(View browser compatibility) |
spelling-error |
A red wavy or dotted line appears under the text to indicate a spelling error.
(Non-standard in CSS3, View browser compatibility) |
grammar-error |
A gray or green wavy or dotted line appears under the text to indicate a grammar error.
(Non-standard in CSS3, View browser compatibility) |
Syntax
/* Single keyword */
text-decoration-line: none;
text-decoration-line: underline;
text-decoration-line: overline;
text-decoration-line: line-through;
text-decoration-line: blink;
/* Multiple keywords */
text-decoration-line: underline overline;
text-decoration-line: overline underline line-through;
/* Global values */
text-decoration-line: inherit;
text-decoration-line: initial;
text-decoration-line: revert;
text-decoration-line: revert-layer;
text-decoration-line: unset;
Formal definition
Initial value | none |
---|---|
Applies to | all elements |
Inherited | no |
Animatable | no |
Practical Examples
Below are practical examples showing how to apply the text-decoration-line
property to text. These cover both single-value and multi-value use cases, along with accessibility considerations.
Single Keyword Value
<p>The text-decoration-line value is underline.</p>
p {
text-decoration-line: underline;
}
The text-decoration-line value is underline.
Multiple Keyword Values
The text-decoration-line
property accepts multiple values separated by spaces.
<p>Multiple text-decoration-line values applied to text.</p>
p {
text-decoration-line: underline overline;
}
Multiple text-decoration-line values applied to text.
Discouraged Usage
Do not use the CSS line-through
value to indicate cancellation or deletion unless the <del>
tag is semantically appropriate.
Using text-decoration-line: line-through
purely for visual effect—such as to suggest that something has been canceled—is not recommended. As shown in the example below, relying on style alone to convey meaning can confuse screen reader users and negatively impact accessibility.
For content that represents deletion or cancellation, use the semantic <del>
tag instead.
<p>Do not use CSS to visually indicate deletion unless the del tag is appropriate.</p>
p {
text-decoration-line: line-through;
}
Do not use CSS to visually indicate deletion unless the del tag is appropriate.
Below is a proper example using the semantic <del>
tag to indicate deletion.
<p>
<del>
Do not use CSS to visually indicate deletion unless the del tag is appropriate.
</del>
</p>
Most modern browsers render the <del>
tag with a strikethrough to visually indicate deleted content.
Do not use CSS to visually indicate deletion unless the del tag is appropriate.
Browser compatibility
Property |
Desktop Chrome
|
DesktopDesktop Edge
|
Desktop Firefox
|
Safari
|
---|---|---|---|---|
text-decoration-line
|
57 | 79 | 36 | 12.1 |
Specifications
Specification | |
---|---|
text-decoration-line
|
CSS Text Decoration Module Level 3 #text-decoration-line-property |
See also
- CSS text-decoration-color Property – Specifies the Color of Text Decorations
- CSS text-decoration-style Property – Specifies the Style of Text Decorations
- CSS text-decoration-thickness Property – Specifies the Thickness of Text Decoration Lines
- CSS text-decoration Property – Shorthand for Text Decoration Styling