text-decoration

lets take a look at the text-decoration property

text-decoration is the CSS property that we use to add line decorations on the text element with colours and styles, or to remove any of them. This property is actually a shorthand for the following CSS properties: - `text-decoration-line` (required) - `text-decoration-color` - `text-decoration-style` - `text-decoration-thickness`

taught by Tina May

you can use text-decoration to add an underline

You can make any text element to have an underline, which is a valid value for text-decoration-line property:

text-decoration:

Oh hey there fellas!

What's brewing, good looking?

You miss 100% of the shots you never take.

you can use text-decoration to remove underline from anchor links

When you create a link, by default it has an underline. If you want to remove that underline, you can override it with text-decoration.

text-decoration:

Oh hey there fellas!

What's brewing, good looking?

You miss 100% of the shots you never take.

you can use text-decoration to add a strikethrough

You can add a strikethrough to any text element, with a value that’s valid for text-decoration-line property:

text-decoration:

Oh hey there fellas!

What's brewing, good looking?

You miss 100% of the shots you never take.

you can apply color to your line decorations

Once you add a line decoration (underline or strikethrough) to any text element, you can apply color to it, using HEX or RGB color code:

text-decoration:

Oh hey there fellas!

What's brewing, good looking?

You miss 100% of the shots you never take.

you can control the thickness of your line decorations

You can control the thickness of your line decoration (underline or strikethrough) either with or without color settings:

text-decoration:

Oh hey there fellas!

What's brewing, good looking?

You miss 100% of the shots you never take.

you can control the style of your line decorations

There are a few styles you can add to your line decorations:

text-decoration:

Oh hey there fellas!

What's brewing, good looking?

You miss 100% of the shots you never take.

explore all typography properties

Select any property below and we’ll show you step-by-step how to use the property, with video demo, tips and practical examples you can code for yourself.

color

font-family

font-size

font-style

font-weight

font

letter-spacing

line-height

list-style

text-align

text-decoration

text-indent

text-overflow

text-shadow

text-transform

vertical-align

word-spacing

Try it for yourself

HTML

<div>
  <h2>Oh hey guys!</h2>
  <p>What's brewing, good looking?</p>
</div>

Oh hey guys!

What's brewing, good looking?

CSS

/* Change the text decoration of the heading*/

h2 { text-decoration: underline #1A4895; }

/* Change the text decoration of the paragraph*/

p { text-decoration: line-through #F9BA4E 2px wavy; }

reults

Let’s change the decorations of each of the following text elements.

Below we’ve put a heading and a paragraph which you can underline or strike through while adding visual effects to it. Otherwise, you can also remove the text decorations entirely.

Try these (or anything else!):

Copyright 2023