Home 〉 CSS Tutorials 〉 CSS text-decoration Property with Examples - Underline, Overline, Line-through, None
CSS text-decoration Property with Examples - Underline, Overline, Line-through, None !
Looking to add or remove text decorations like underlines? The CSS `text-decoration` property allows you to specify decorations such as underline, overline, line-through, or none. This tutorial demonstrates how to apply these styles and combine them for various effects. You'll also learn about the shorthand notation for setting multiple decoration properties at once. Enhance your text styling with this property. Check out the our detailed post on CSS text-decoration Property with Examples
The 'text-decoration' property in CSS is used to add or remove decorations from text, like underlines or strike-throughs. It's commonly used to style links, headings, or any inline content.
Syntax ✍
selector {
text-decoration: value;
}
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<p style="text-decoration: underline;">This text is underlined.</p>
</body>
</html>
output 📌
This text is underlined.
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Meaning: A line appears 'under' the text.
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<p style="text-decoration: overline;">This text has an overline.</p>
</body>
</html>
output 📌
This text has an overline.
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Meaning: A line appears 'above' the text.
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<p style="text-decoration: line-through;">This text has a line through it.</p>
</body>
</html>
output 📌
This text has a line through it.
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Meaning: A horizontal line strikes through the middle of the text.
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<a href="#" style="text-decoration: none;">Click here</a>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Meaning: Removes the default underline from a hyperlink.
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<p style="text-decoration: underline overline;">This text has underline and overline.</p>
</body>
</html>
output 📌
This text has underline and overline.
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Meaning: Adds both underline and overline to the same text.
In modern CSS, you can break 'text-decoration' into multiple properties:
<!DOCTYPE html>
<html>
<head>
<style>
.p-class {
text-decoration-line: underline;
text-decoration-color: red;
text-decoration-style: wavy;
text-decoration-thickness: 2px;
}
</style>
</head>
<body>
<p class="p-class">This text has multiple properties.</p>
</body>
</html>
output 📌
This text has multiple properties.
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
The 'text-decoration' property helps you control the visual style of your text. Whether you're adding emphasis with underline or removing default link styling, this property is simple yet powerful.
Use 'text-decoration: none;' on the anchor ('<a>') element.
Yes. Example: 'text-decoration: underline overline;'
'text-decoration' is shorthand. 'text-decoration-line' is a specific sub-property for lines only.
Yes. Use 'text-decoration-color'. Example: 'text-decoration-color: red;'
Yes, it's widely supported across all modern and older browsers.