CSS text-decoration-style Property
The CSS text-decoration-style property specifies the appearance of text decoration lines, including solid, double, dotted, dashed, and wavy styles.
It works with text-decoration-line to style underlines, overlines, and strikethroughs. The property changes how a decoration is drawn without changing the text itself or its layout.
The default value is solid. To display a decoration, specify a line using text-decoration-line or the text-decoration shorthand.
text-decoration-style Syntax
The property accepts one keyword specifying the style of the text decoration line.
Basic Syntax
.example {
text-decoration-style: solid;
}
Available Values
.example {
text-decoration-style: solid;
}
.example {
text-decoration-style: double;
}
.example {
text-decoration-style: dotted;
}
.example {
text-decoration-style: dashed;
}
.example {
text-decoration-style: wavy;
}
Only one decoration style can be specified per declaration.
CSS-Wide Keywords
.example {
text-decoration-style: initial;
}
.example {
text-decoration-style: inherit;
}
.example {
text-decoration-style: unset;
}
.example {
text-decoration-style: revert;
}
.example {
text-decoration-style: revert-layer;
}
The initial keyword restores solid. Because the property is not inherited, unset also restores the initial value.
Valid Examples
a {
text-decoration-line: underline;
text-decoration-style: solid;
}
.heading {
text-decoration-line: underline;
text-decoration-style: double;
}
.note {
text-decoration-line: underline;
text-decoration-style: dotted;
}
.example {
text-decoration-line: underline;
text-decoration-style: dashed;
}
.warning {
text-decoration-line: underline;
text-decoration-style: wavy;
}
Invalid Examples
.example {
text-decoration-style: thick;
}
.example {
text-decoration-style: red;
}
.example {
text-decoration-style: underline;
}
.example {
text-decoration-style: solid dotted;
}
.example {
text-decoration-style: 3px;
}
These declarations are invalid because thickness, color, decoration type, and multiple style keywords are not accepted values.
Property Values
| Value | Description |
|---|---|
solid |
Draws a single continuous decoration line. |
double |
Draws two parallel decoration lines. |
dotted |
Draws a decoration consisting of dots. |
dashed |
Draws a decoration consisting of short line segments. |
wavy |
Draws a wave-shaped decoration line. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | solid |
| Inherited | No |
| Applies to | All elements |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
| Shorthand | text-decoration |
| Specification | CSS Text Decoration Module Level 3 |
Note: The property itself is not inherited. However, text decorations can propagate from an ancestor to descendant inline content, so a child element may appear decorated even without its own decoration declarations.
How It Works
The text-decoration-style property changes the visual pattern of an existing decoration line.
Step 1: Create a Decoration
.example {
text-decoration-line: underline;
}
The browser draws a solid underline by default.
Step 2: Change the Style
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
}
The underline is drawn using a dotted pattern.
Step 3: Set the Color
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
text-decoration-color: #2563eb;
}
The dots use the specified blue decoration color.
Step 4: Adjust Thickness
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
text-decoration-color: #2563eb;
text-decoration-thickness: 3px;
}
The browser draws a thicker dotted underline.
Step 5: Adjust the Underline Offset
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
text-decoration-color: #2563eb;
text-decoration-thickness: 3px;
text-underline-offset: 4px;
}
The underline is positioned farther from the text.
Important Consideration
Changing the decoration style does not change the text's dimensions or layout. The exact appearance of dots, dashes, double lines, and waves depends on browser rendering and decoration thickness.
The solid Value
The solid keyword draws a single continuous decoration line. It is the initial value.
Basic Example
.example {
text-decoration-line: underline;
text-decoration-style: solid;
}
Solid Overline
.example {
text-decoration-line: overline;
text-decoration-style: solid;
}
Solid Strikethrough
.example {
text-decoration-line: line-through;
text-decoration-style: solid;
}
Colored Solid Underline
.example {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: #2563eb;
}
Using the Shorthand
.example {
text-decoration: underline solid #2563eb;
}
The shorthand produces the same underline color and style.
When solid Is Useful
Solid decorations are commonly used for hyperlinks, headings, and deleted text. They are familiar and generally easy to recognize.
Important Consideration
A solid underline may still contain small gaps around glyph descenders when text-decoration-skip-ink is enabled. Solid describes the line style, not whether glyph intersections are skipped.
The double Value
The double keyword draws two parallel decoration lines instead of one.
Basic Example
.example {
text-decoration-line: underline;
text-decoration-style: double;
}
Double Overline
.example {
text-decoration-line: overline;
text-decoration-style: double;
}
Double Strikethrough
.example {
text-decoration-line: line-through;
text-decoration-style: double;
}
Colored Double Underline
.example {
text-decoration-line: underline;
text-decoration-style: double;
text-decoration-color: #7c3aed;
}
Adjusting Thickness
.example {
text-decoration-line: underline;
text-decoration-style: double;
text-decoration-thickness: 3px;
}
Decoration thickness influences the appearance of the two lines. Their exact spacing is determined by the browser.
Using the Shorthand
.example {
text-decoration: underline double #7c3aed;
}
When double Is Useful
Double decorations can provide emphasis in headings, labels, and specialized typography.
Important Consideration
At small font sizes, the two lines may be difficult to distinguish. Test the decoration thickness and contrast before using double underlines for important content.
The dotted Value
The dotted keyword draws a decoration using a series of dots.
Basic Example
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
}
Dotted Overline
.example {
text-decoration-line: overline;
text-decoration-style: dotted;
}
Dotted Strikethrough
.example {
text-decoration-line: line-through;
text-decoration-style: dotted;
}
Colored Dotted Underline
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
text-decoration-color: #059669;
}
Adjusting Thickness
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
text-decoration-thickness: 3px;
}
Increasing thickness makes the dots more prominent.
Using the Shorthand
.example {
text-decoration: underline dotted #059669 2px;
}
When dotted Is Useful
Dotted underlines can distinguish secondary links, abbreviations, and explanatory text from standard solid-underlined links.
Important Consideration
A dotted underline does not automatically make text interactive. Use an appropriate HTML element, such as <a> for links or <abbr> for abbreviations.
The dashed Value
The dashed keyword draws a decoration using short line segments separated by gaps.
Basic Example
.example {
text-decoration-line: underline;
text-decoration-style: dashed;
}
Dashed Overline
.example {
text-decoration-line: overline;
text-decoration-style: dashed;
}
Dashed Strikethrough
.example {
text-decoration-line: line-through;
text-decoration-style: dashed;
}
Colored Dashed Underline
.example {
text-decoration-line: underline;
text-decoration-style: dashed;
text-decoration-color: #ea580c;
}
Adjusting Thickness
.example {
text-decoration-line: underline;
text-decoration-style: dashed;
text-decoration-thickness: 3px;
}
The dashes become thicker, although their lengths and spacing remain browser-controlled.
Using the Shorthand
.example {
text-decoration: underline dashed #ea580c 2px;
}
When dashed Is Useful
Dashed decorations can provide a distinct visual style for labels, references, and emphasized text.
Important Consideration
CSS does not provide individual dash-length or dash-gap controls through text-decoration-style. The browser determines the pattern.
The wavy Value
The wavy keyword draws a wave-shaped decoration line.
Basic Example
.example {
text-decoration-line: underline;
text-decoration-style: wavy;
}
Wavy Overline
.example {
text-decoration-line: overline;
text-decoration-style: wavy;
}
Wavy Strikethrough
.example {
text-decoration-line: line-through;
text-decoration-style: wavy;
}
Colored Wavy Underline
.example {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: #dc2626;
}
Adjusting Thickness
.example {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-thickness: 2px;
}
The thickness changes while the wave pattern remains controlled by the browser.
Using the Shorthand
.example {
text-decoration: underline wavy #dc2626 2px;
}
When wavy Is Useful
Wavy underlines are commonly associated with spelling or grammar indicators. They can also be used for custom annotations or decorative emphasis.
Important Consideration
Applying a red wavy underline does not automatically identify a spelling error or provide an explanation. If the decoration communicates a warning or validation error, provide that information in accessible text as well.
Decoration Line Types
The text-decoration-style property works with the decoration lines specified by text-decoration-line.
Underline
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
}
Draws a dotted line beneath the text.
Overline
.example {
text-decoration-line: overline;
text-decoration-style: dashed;
}
Draws a dashed line above the text.
Line-Through
.example {
text-decoration-line: line-through;
text-decoration-style: double;
}
Draws a double-line strikethrough across the text.
Multiple Decoration Lines
.example {
text-decoration-line: underline overline;
text-decoration-style: wavy;
}
Both decoration lines use the wavy style.
Combining All Three Line Types
.example {
text-decoration-line: underline overline line-through;
text-decoration-style: dashed;
}
All three decoration lines use the same dashed style.
Important Consideration
A single text-decoration-style declaration applies the same style to all decoration lines established by that element. It cannot assign different styles to an underline and overline within the same declaration.
Using the text-decoration Shorthand
The text-decoration shorthand combines decoration line, style, color, and thickness in one declaration.
Solid Underline
.example {
text-decoration: underline solid;
}
Dotted Underline
.example {
text-decoration: underline dotted;
}
Dashed Underline With Color
.example {
text-decoration: underline dashed #2563eb;
}
Wavy Underline With Thickness
.example {
text-decoration: underline wavy #dc2626 2px;
}
Double Overline
.example {
text-decoration: overline double #7c3aed;
}
Multiple Decoration Lines
.example {
text-decoration: underline overline dotted #059669;
}
Shorthand Reset Behavior
The shorthand resets its constituent longhand properties, including text-decoration-style.
.example {
text-decoration-style: wavy;
text-decoration: underline;
}
The second declaration resets the decoration style to solid.
Preserving the Style
.example {
text-decoration: underline;
text-decoration-style: wavy;
}
The later longhand declaration changes the underline to wavy.
Important Consideration
The text-decoration shorthand does not include text-decoration-skip-ink, text-underline-offset, or text-underline-position. Specify those properties separately when needed.
Related Properties
Several properties work together to control the appearance and positioning of text decorations.
| Property | Purpose |
|---|---|
text-decoration |
Shorthand for decoration line, style, color, and thickness. |
text-decoration-line |
Specifies underline, overline, and line-through decorations. |
text-decoration-color |
Controls the color of decoration lines. |
text-decoration-thickness |
Controls the thickness of decoration lines. |
text-decoration-skip-ink |
Controls interruptions where underlines and overlines intersect glyph ink. |
text-underline-offset |
Adjusts the position of an underline relative to its normal position. |
text-underline-position |
Controls where an underline is positioned. |
Combining Related Properties
.example {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: #2563eb;
text-decoration-thickness: 2px;
text-decoration-skip-ink: auto;
text-underline-offset: 3px;
}
This creates a blue wavy underline with a custom thickness and offset.
Decoration Propagation
Text decorations can propagate from a parent element into descendant inline content. The decoration's style is determined by the element that establishes the decoration.
.parent {
text-decoration-line: underline;
text-decoration-style: wavy;
}
.parent span {
text-decoration-style: dotted;
}
The child does not change the parent's wavy underline to dotted. The child's declaration would affect a decoration established by the child itself.
Adding a Separate Child Decoration
.parent {
text-decoration-line: underline;
text-decoration-style: wavy;
}
.parent span {
text-decoration-line: overline;
text-decoration-style: dotted;
}
The parent establishes a wavy underline, while the child establishes its own dotted overline.
Practical Examples
Standard Link Underline
a {
text-decoration-line: underline;
text-decoration-style: solid;
}
Creates a familiar solid underline for hyperlinks.
Dotted Abbreviation Underline
abbr[title] {
text-decoration-line: underline;
text-decoration-style: dotted;
text-underline-offset: 3px;
}
Creates a dotted underline for abbreviations with explanatory titles.
Double Heading Underline
.heading {
text-decoration-line: underline;
text-decoration-style: double;
text-decoration-color: #2563eb;
}
Creates a double underline beneath a heading.
Dashed Reference Link
.reference-link {
text-decoration-line: underline;
text-decoration-style: dashed;
text-decoration-color: currentColor;
}
Uses a dashed underline that follows the text color.
Wavy Validation Indicator
.invalid-text {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: #dc2626;
}
Creates a visual indicator that can accompany an accessible validation message.
Dotted Strikethrough
.old-value {
text-decoration-line: line-through;
text-decoration-style: dotted;
}
Applies a dotted line through the text.
Double Overline
.overline-label {
text-decoration-line: overline;
text-decoration-style: double;
text-decoration-color: #7c3aed;
}
Creates two parallel lines above the text.
Wavy Underline With Offset
.wavy-link {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: #059669;
text-decoration-thickness: 2px;
text-underline-offset: 4px;
}
Positions a green wavy underline farther from the text.
Hover Decoration Style
.hover-link {
text-decoration-line: underline;
text-decoration-style: solid;
}
.hover-link:hover {
text-decoration-style: dashed;
}
Changes the underline from solid to dashed when the pointer hovers over the link.
Keyboard Focus Styling
.focus-link {
text-decoration-line: underline;
text-decoration-style: solid;
}
.focus-link:focus-visible {
text-decoration-style: double;
outline: 2px solid currentColor;
outline-offset: 3px;
}
Changes the decoration style and adds a visible focus outline for keyboard navigation.
text-decoration-style Example
This example displays all five decoration styles using the same text, color, and underline thickness.
HTML Example
<div class="decoration-style-demo">
<div class="style-sample">
<strong>solid</strong>
<p class="style-solid">CSS Text Decoration</p>
</div>
<div class="style-sample">
<strong>double</strong>
<p class="style-double">CSS Text Decoration</p>
</div>
<div class="style-sample">
<strong>dotted</strong>
<p class="style-dotted">CSS Text Decoration</p>
</div>
<div class="style-sample">
<strong>dashed</strong>
<p class="style-dashed">CSS Text Decoration</p>
</div>
<div class="style-sample">
<strong>wavy</strong>
<p class="style-wavy">CSS Text Decoration</p>
</div>
</div>
CSS Example
.decoration-style-demo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px;
}
.decoration-style-demo .style-sample {
padding: 16px;
border: 1px solid #cbd5e1;
background: #f8fafc;
}
.decoration-style-demo strong {
display: block;
margin-bottom: 12px;
color: #334155;
font-size: 14px;
}
.decoration-style-demo p {
margin: 0;
color: #1f2937;
font-size: 22px;
line-height: 1.8;
text-decoration-line: underline;
text-decoration-color: #2563eb;
text-decoration-thickness: 2px;
text-underline-offset: 4px;
}
.decoration-style-demo .style-solid {
text-decoration-style: solid;
}
.decoration-style-demo .style-double {
text-decoration-style: double;
}
.decoration-style-demo .style-dotted {
text-decoration-style: dotted;
}
.decoration-style-demo .style-dashed {
text-decoration-style: dashed;
}
.decoration-style-demo .style-wavy {
text-decoration-style: wavy;
}
CSS Text Decoration
CSS Text Decoration
CSS Text Decoration
CSS Text Decoration
CSS Text Decoration
Comparing the Results
| Style | Expected Appearance |
|---|---|
solid |
A single continuous underline, except for possible glyph ink skipping. |
double |
Two parallel underline segments. |
dotted |
A series of dots beneath the text. |
dashed |
Short line segments separated by gaps. |
wavy |
A wave-shaped underline. |
The browser determines the exact spacing and shapes of the decoration patterns. The examples may appear slightly different across browsers and operating systems.
Changing the Decoration Color
.decoration-style-demo p {
text-decoration-color: #dc2626;
}
All five styles change to red.
Changing the Decoration Thickness
.decoration-style-demo p {
text-decoration-thickness: 4px;
}
The decoration patterns become thicker.
Changing the Decoration Line
.decoration-style-demo p {
text-decoration-line: overline;
}
All five styles appear above the text instead of below it.
Accessibility Considerations
Text decoration styles can help distinguish content, but their appearance should remain clear and understandable.
Keep Links Recognizable
Use visible link styling so users can identify interactive text. Solid underlines are familiar and generally easy to recognize.
Maintain Decoration Contrast
Choose decoration colors that remain distinguishable from the background.
Avoid Extremely Thin Patterns
Very thin dotted or dashed lines may be difficult to see, especially at small font sizes or high zoom levels.
Do Not Rely on Decoration Style Alone
If a wavy underline indicates an error, include a readable error message rather than communicating the problem only through the decoration.
Provide Visible Keyboard Focus
Changing the underline style on focus can help, but a clear focus outline is often more reliable.
Use Semantic HTML
Use <a> for links, <del> for deleted content, and other appropriate elements when the decoration communicates meaning.
Test Text Resizing
Verify that decoration patterns remain visible when users enlarge text or increase browser zoom.
Consider Familiar Conventions
Wavy red underlines are commonly associated with spelling or validation errors. Avoid using them decoratively where they could confuse readers.
Common Mistakes
Expecting the Property to Create an Underline
.example {
text-decoration-style: dotted;
}
This declaration changes the style of an existing decoration but does not create one.
Correct Example
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
}
Using Multiple Style Values
.example {
text-decoration-style: solid wavy;
}
Only one style keyword is permitted.
Using a Thickness Keyword
.example {
text-decoration-style: thick;
}
Use text-decoration-thickness to control thickness.
Using a Color Value
.example {
text-decoration-style: red;
}
Use text-decoration-color to control color.
Using a Decoration Line Value
.example {
text-decoration-style: underline;
}
Use text-decoration-line to specify underline, overline, or line-through.
Using a Length Value
.example {
text-decoration-style: 3px;
}
Length values belong to properties such as text-decoration-thickness and text-underline-offset.
Forgetting Shorthand Reset Behavior
.example {
text-decoration-style: wavy;
text-decoration: underline;
}
The shorthand resets the style to solid.
Assuming the Property Is Inherited
The property is not inherited. Parent decorations may propagate visually, but the child's computed text-decoration-style remains independent.
Expecting Different Styles on Multiple Lines
One declaration cannot assign a dotted underline and a dashed overline to the same decoration set.
Expecting Identical Patterns Across Browsers
Browsers determine the precise shapes and spacing of dots, dashes, and waves.
Using Wavy Underlines Without Context
Wavy underlines may suggest errors. Provide clear context when using them for another purpose.
Important Considerations
Keep the following points in mind when using text-decoration-style:
- The property controls the appearance of text decoration lines.
- It accepts
solid,double,dotted,dashed, andwavy. - The initial value is
solid. - The property is not inherited.
- The property does not create a decoration line.
- Use
text-decoration-lineto create underlines, overlines, and strikethroughs. - The property works with all three decoration line types.
- Multiple decoration lines use the same style when established by one element.
- The property is a longhand component of
text-decoration. - The shorthand can reset the style to its initial value.
- Use
text-decoration-colorto change decoration color. - Use
text-decoration-thicknessto change decoration thickness. - Use
text-underline-offsetto adjust underline position. - Use
text-decoration-skip-inkto control glyph ink skipping. - Decoration styling does not change the text's layout dimensions.
- Decoration lines can propagate from ancestors into descendant inline content.
- A child's style declaration does not restyle a decoration established by its parent.
- Browsers determine the exact shapes of dotted, dashed, and wavy patterns.
- Double decorations contain two parallel lines.
- Very thin decorations may be difficult to see.
- Thicker decorations can make patterns more noticeable.
- Wavy underlines are commonly associated with spelling and validation indicators.
- Use semantic HTML when decorations communicate meaning.
- Maintain recognizable link styling.
- Provide accessible text for warnings and errors.
- Test decoration appearance across browsers and fonts.
- Verify that decorations remain visible at increased text sizes.
Browser Support
The CSS text-decoration-style property is widely available in modern browsers, including Chrome, Edge, Firefox, and Safari.
All five values are supported in current major browsers. The exact rendering of dots, dashes, double lines, and waves may differ between browser engines.
For current compatibility information, visit Can I Use? and search for text-decoration-style.
Basic Compatibility
.example {
text-decoration-line: underline;
text-decoration-style: dotted;
}
Dotted underlines are supported in current major browsers.
Wavy Decoration
.example {
text-decoration-line: underline;
text-decoration-style: wavy;
}
Wavy decorations are also supported in modern browsers.
Feature Detection
@supports (text-decoration-style: wavy) {
.example {
text-decoration-style: wavy;
}
}
This checks whether the browser recognizes the wavy decoration style.
Fallback Example
.example {
text-decoration: underline solid;
text-decoration-style: wavy;
}
If a browser does not recognize the wavy style, the solid underline remains available as a fallback.
Testing Recommendations
Test different decoration styles with the actual font, text size, and thickness used on the page. Pay particular attention to the visibility of dotted and double decorations at smaller sizes.
Specifications
The text-decoration-style property is defined in the CSS Text Decoration Module Level 3 specification.
CSS Text Decoration Module Level 3 - text-decoration-style Property
The specification defines the five decoration styles and their relationship to underlines, overlines, and line-through decorations.
For additional documentation and examples, consult MDN Web Docs.
