Currently Empty: ₹0.00
CSS Text Decoration
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
| Value | Purpose |
|---|---|
underline | Adds a line below the text. |
overline | Adds a line above the text. |
line-through | Draws a line through the text. |
none | Removes 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.
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
Decoration line
Decoration color
Decoration style
Decoration thickness
🧱 Individual Text Decoration Properties
| Property | Purpose | Example |
|---|---|---|
text-decoration-line | Sets the decoration type. | underline |
text-decoration-color | Sets decoration color. | #087fbc |
text-decoration-style | Sets line style. | wavy |
text-decoration-thickness | Sets line thickness. | 3px |
text-decoration | Shorthand 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;
}A common website design pattern is to remove the underline
normally and display it when the user hovers over the link.
💡 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:
-
Create an
h1with an underline. -
Create an
h2with an overline. -
Create a price with
line-through. - Remove the underline from a link.
- Create a dotted underline.
- Create a dashed underline.
- Create a wavy underline.
- Change the decoration color.
-
Increase the decoration thickness to
5px. - Create a custom decoration using the shorthand property.
📚 Quick Reference
| CSS | Purpose | Example |
|---|---|---|
| text-decoration | Main shorthand property. | underline |
| text-decoration-line | Sets line type. | underline |
| text-decoration-color | Sets line color. | #087fbc |
| text-decoration-style | Sets line style. | wavy |
| text-decoration-thickness | Sets line thickness. | 3px |
| underline | Line below text. | text-decoration: underline; |
| overline | Line above text. | text-decoration: overline; |
| line-through | Line through text. | text-decoration: line-through; |
| none | No 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.
SNCEC PORTAL
Student & Website Links
Quick access to student services, courses, learning resources and SNCEC information.
Student Login
Access your student account
Student Registration
Create your student account
Student Dashboard
Manage your learning activities
Courses
Explore our job-oriented courses
All Courses List
View complete course catalog
Instructor Registration
Join us as an instructor
Our Team
Meet our professional team
About Us
Learn more about SNCEC
Contact Us
Get in touch with our team
Mock Tests & Quizzes
Practice and test your knowledge
Student Zone
Access student services and resources
Student Zone →Learning Portal
Access online learning resources
Open Portal →Computer Shop
Computers, accessories & IT products
SNCEC Official Website
Shree Narayan Computers & Education Center



