Introduction to text-decoration-line in CSS ποΈ
The text-decoration-line property in CSS specifies what kind of decorative line should be applied to text. It allows you to add effects like underline, overline, or line-through, and is commonly used for styling links, headings, labels, and highlighted text. This gives your UI more control and precision over its typography! π₯
Why Use text-decoration-line? π€
- To style links with custom underline effects π
- To strike out deprecated or incorrect content β
- To highlight text with overlines or multiple lines β¨
- To create custom visual effects in headings π¨
Syntax π
Basic Syntax
selector {
text-decoration-line: none | underline | overline | line-through | blink | multiple-values;
}Note
Available Values π§©
1. none
Removes all text decorations.
2. underline β¬οΈ
Draws a line below the text. Commonly used for links.
3. overline β¬οΈ
Draws a line above the text.
4. line-through β
Strikes through the text. Used for showing deleted or discounted prices.
5. multiple values β¨
You can combine decorations like: underline overline.
Examples π₯
1. Underlined Link
Underline example
a {
text-decoration-line: underline;
}2. Line-Through Text (e.g., Old Price) π·οΈ
Line-through example
.old-price {
text-decoration-line: line-through;
}3. Overline Effect
Overline example
h1 {
text-decoration-line: overline;
}4. Combining Underline + Overline β¨
Multiple lines
h2 {
text-decoration-line: underline overline;
}Comparison Table π
| Value | Description |
|---|---|
| none | No decoration applied |
| underline | Draws a line under the text |
| overline | Draws a line above the text |
| line-through | Strike-through the text |
| underline overline | Applies both top and bottom lines |
Visual Example πΌοΈ
Further details can be found at: https://dummyimage.com/800x220/eeeeee/000000&text=underline+|+overline+|+line-through
Conclusion π
The text-decoration-line property gives you full control over text decoration styles. From underlines to strike-throughs and combined effects, you can style text with precision and creativity. Pair it with text-decoration-color andtext-decoration-style for even more beautiful designs! π