Code has been added to clipboard!

The CSS Text-Decoration Property

Reading time 2 min
Published Aug 8, 2017
Updated Sep 27, 2019

Using text decorations in CSS

The CSS text-decoration property specifies visual decorative lines for text:

Example
h1 {
    text-decoration: underline overline dotted red;
}

h2 {
    text-decoration: underline overline wavy blue;
}

This property is actually a shorthand for four subproperties:

  • text-decoration-color
  • text-decoration-line
  • text-decoration-style
  • text-decoration-thickness

As with all shorthands, you need to list the values without naming the subproperties:

text-decoration: color line style thickness;

You don't need to define all the values for the shorthand to work – it will work with even a single value:

Example
h1 {
    text-decoration: overline;
}

h2 {
    text-decoration: line-through;
}

h3 {
    text-decoration: underline;
}

h4 {
    text-decoration: underline overline;
}

In the following sections, we will explain each subproperty individually.

Modifying the CSS text decoration line

Using the CSS text-decoration-line property allows you to specify what kind of line the text decoration is going to use:

Example
p {
    text-decoration-line: overline;  
}  
p.lines-everywhere {
    text-decoration-line: overline underline line-through;
}

The syntax for this property is simple:

text-decoration-line: value;

You may combine different possible values in one statement as well.

Value Description
none The default value. No text decoration line is displayed
underline Makes CSS underline text
overline Makes CSS overline text
line-through Makes CSS draw a line across text
blink A deprecated value. Made the text blink in CSS

Coloring the decoration line

The CSS text-decoration-color allows you to set the color for CSS underlines, overlines, and line-throughs:

Example
p {
    text-decoration: overline;
    text-decoration-color: green;
}

The syntax for this property is almost the same as the ones discussed above:

text-decoration-color: color;

You can define the color using a name, RGB, RGBA, HEX, HSL or HSLA value.

Tip: to get the value for the exact color tone you need, use the Pickeristic color picker.

Styling CSS text decorations

The CSS text-decoration-style allows you to define how to display the text decoration line:

Example
a {
    text-decoration: overline; 
    text-decoration-style: dashed; 
}

The syntax for this property is as follows:

text-decoration-style: value;

All the available values are listed in the table below.

Value Description
solid The default value. Displays as a single straight line
double Display a double line
dotted Display a dotted line
dashed Display a dashed line
wavy Display a wavy line

Defining line thickness

The last CSS text decoration subproperty is called text-decoration-thickness. It sets the width of the decoration line:

text-decoration-thickness: value;

You can define the thickness in either length units or keywords:

  • auto is the default value which makes the browser choose the line thickness
  • from-font chooses the thickness according to the font-size

Note: CSS text-decoration-thickness is an experimental property, so be aware of lower browser support.

Browser support

Chrome
1+
Edge
12+
Firefox
1+
IE
3+
Opera
3.5+
Safari
1+

Mobile browser support

Chrome
18+
Firefox
4+
Opera
All
Safari
All
Tutorial
CSS3 Features
Syntax
Classes
ID Selectors
Attribute Selectors
Stylesheets
Inline
Internal
External
Box Model
Children Selectors
Pseudo Classes
Pseudo Elements
Variables
Counters
Text
Fonts
Web Fonts
Backgrounds
Background Images
Colors
Gradients
Opacity / Transparency
Shadow Effects
Transitions
Tooltip
Transform
Animations
Layout — Display
Layout — Position
Layout — Float
Layout — Clear
Layout — Horizontal & Vertical Align
Multiple Columns
Introduction
Responsive Web Design — Viewport
Responsive Web Design — Grid View
Responsive Web Design — Media Queries
Responsive Web Design — Flexbox Layout
Responsive Web Design — Images
Responsive Web Design — Videos
Borders
Margin
Padding
Width
Height
Outline
Links
Lists
Tables
Dropdown Menu
Navigation Bar
Images
Image Gallery
Border Images
Forms
Rounded Corners
Buttons
Box-Sizing
Selector Reference
Pagination Examples
Code Examples
CSS3 Browser Support Reference
Functions Reference
Speech Module Reference
Units
Web Safe Font Combinations
Cheat Sheet
:hover
@font-face
@keyframes
@media
align-content
align-items
align-self
all
animation
backface-visibility
background
background-clip
background-color
background-image
background-origin
background-position
background-size
border
border-image
border-radius
border-style
box-shadow
box-sizing
color
columns
filter
flex
flex-basis
flex-direction
flex-flow
flex-grow
flex-shrink
flex-wrap
font
font-family
font-size
font-size-adjust
font-stretch
font-style
font-weight
hanging-punctuation
justify-content
line-height
margin
offset
opacity
order
outline
overflow
padding
perspective
position
resize
tab-size
text-align
text-decoration
text-emphasis
text-transform
text-shadow
transform
transition-property
translate
vertical-align
word-break
word-wrap
z-index