Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape

CSS Text Decoration

CSS Text Decoration

CSS Text Decoration – CSS Tutorial | Shree Narayan Computers & Education Center
CSS COURSE • LESSON

CSS Text Decoration

Learn how to decorate text using CSS. Understand underline, overline, line-through, decoration style, color, thickness and the text-decoration shorthand property with practical examples.

📘 What is CSS Text Decoration?

The CSS text-decoration property is used to add decorative lines to text.

You can use it to create underlined text, overlined text, crossed-out text and more advanced decoration effects.

In simple words: CSS text decoration controls lines that appear around or through text.

🧩 CSS Text Decoration Syntax

selector {
    text-decoration: value;
}

The most common values are underline, overline, line-through and none.

🔑 Text Decoration Values

ValuePurpose
underlineAdds a line below the text.
overlineAdds a line above the text.
line-throughDraws a line through the text.
noneRemoves text decoration.

🔵 Example 1: Underline

Use text-decoration: underline; to place a line below text.

h2 {
    text-decoration: underline;
}
This text is underlined.

🔼 Example 2: Overline

Use overline to place a line above the text.

h2 {
    text-decoration: overline;
}
This text has an overline.

❌ Example 3: Line Through

The line-through value draws a line through the text.

.price {
    text-decoration: line-through;
}
Old Price ₹999

🚫 Example 4: Remove Decoration

Use text-decoration: none; to remove an existing text decoration.

See also  CSS Flex Basis

a {
    text-decoration: none;
}
This is commonly used when styling navigation links and buttons.

↕️ Example 5: Underline + Overline

You can apply more than one decoration at the same time.

h2 {
    text-decoration:
        underline
        overline;
}
Underline and Overline

🎨 Text Decoration Style

The text-decoration-style property controls the visual style of the decoration line.

Solid

Solid underline

Dotted

Dotted underline

Dashed

Dashed underline

Wavy

Wavy underline

💻 Decoration Style Code

.text {
    text-decoration-line: underline;
    text-decoration-style: wavy;
}

Common styles include: solid, double, dotted, dashed and wavy.

🌈 Text Decoration Color

Use text-decoration-color to change the color of the decoration line.

.text {
    text-decoration-line: underline;
    text-decoration-color: #087fbc;
}
Blue Decoration

📏 Text Decoration Thickness

The text-decoration-thickness property controls the thickness of the decoration line.

.text {
    text-decoration-line: underline;
    text-decoration-thickness: 4px;
}
Thick Underline

⚡ Text Decoration Shorthand

The text-decoration property can combine multiple decoration settings into one declaration.

.text {
    text-decoration:
        underline
        #087fbc
        wavy
        3px;
}
Wavy Blue Underline
Shorthand can specify:
Decoration line
Decoration color
Decoration style
Decoration thickness

🧱 Individual Text Decoration Properties

PropertyPurposeExample
text-decoration-lineSets the decoration type.underline
text-decoration-colorSets decoration color.#087fbc
text-decoration-styleSets line style.wavy
text-decoration-thicknessSets line thickness.3px
text-decorationShorthand property.underline #087fbc wavy 3px

🔗 CSS Text Decoration and Links

Browsers commonly display links with an underline. You can remove that underline with CSS.

a {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

💡 Practical Uses

🔗 Website Links

Style normal and hover states of hyperlinks.

💰 Discount Prices

Use line-through to show an old price.

📝 Important Text

Use underline to highlight important information.

🎨 Creative Typography

Use wavy, dashed or dotted decorations for design effects.

⚠️ Common Mistakes

  • Using too many decorative lines on normal text.
  • Using low-contrast decoration colors.
  • Making decoration thickness too large.
  • Forgetting to remove default link decoration when creating custom navigation.
  • Using decorative styles that reduce readability.
Remember: Text decoration should support readability and visual hierarchy. Avoid decorative effects that make text difficult to read.

📝 Practice Exercises

Open your HTML Runner and complete these exercises:

  1. Create an h1 with an underline.
  2. Create an h2 with an overline.
  3. Create a price with line-through.
  4. Remove the underline from a link.
  5. Create a dotted underline.
  6. Create a dashed underline.
  7. Create a wavy underline.
  8. Change the decoration color.
  9. Increase the decoration thickness to 5px.
  10. Create a custom decoration using the shorthand property.

📚 Quick Reference

CSSPurposeExample
text-decorationMain shorthand property.underline
text-decoration-lineSets line type.underline
text-decoration-colorSets line color.#087fbc
text-decoration-styleSets line style.wavy
text-decoration-thicknessSets line thickness.3px
underlineLine below text.text-decoration: underline;
overlineLine above text.text-decoration: overline;
line-throughLine through text.text-decoration: line-through;
noneNo decoration.text-decoration: none;

🎓 Key Points to Remember

  • text-decoration adds decorative lines to text.
  • underline places a line below text.
  • overline places a line above text.
  • line-through draws a line through text.
  • none removes decoration.
  • text-decoration-style controls the line style.
  • text-decoration-color controls the line color.
  • text-decoration-thickness controls line thickness.
  • Multiple decoration properties can be combined using shorthand.
See also  CSS Letter Spacing

HTML Forms

  • 17/08/2026

CSS Box Model

  • 18/08/2026

CSS Flex Flow

  • 19/08/2026

Leave a Reply

Your email address will not be published. Required fields are marked *