CSS Properties
CSS text-decoration-style Property
Photo Credit to CodeToFun
🙋 Introduction
The text-decoration-style
property in CSS allows developers to define the style of text decorations applied to text content.
This property can be used to customize the appearance of text underlines, overlines, and line-throughs, giving you control over the visual style of these text decorations. It enhances the ability to create visually distinct and appealing text presentations.
💡 Syntax
The syntax for the text-decoration-style
property is simple. It can be applied to any text element to define the style of the text decoration.
element {
text-decoration-style: style;
}
Here, style can be one of the predefined values that determine the appearance of the text decoration.
🎛️ Default Value
The default value of the text-decoration-style
property is solid, which applies a solid line to the text decoration.
🏠 Property Values
Value | Description |
---|---|
solid | A solid line. |
double | Two parallel solid lines. |
dotted | A dotted line. |
dashed | A dashed line. |
wavy | A wavy line. |
📄 Example
In this example, we'll apply different text-decoration styles to various text elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS text-decoration-style Example</title>
<style>
.solid {
text-decoration: underline;
text-decoration-style: solid;
}
.double {
text-decoration: underline;
text-decoration-style: double;
}
.dotted {
text-decoration: underline;
text-decoration-style: dotted;
}
.dashed {
text-decoration: underline;
text-decoration-style: dashed;
}
.wavy {
text-decoration: underline;
text-decoration-style: wavy;
}
</style>
</head>
<body>
<h1>Text Decoration Style Examples</h1>
<p class="solid">This is a solid underline.</p>
<p class="double">This is a double underline.</p>
<p class="dotted">This is a dotted underline.</p>
<p class="dashed">This is a dashed underline.</p>
<p class="wavy">This is a wavy underline.</p>
</body>
</html>
🖥️ Browser Compatibility
The text-decoration-style
property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.
🎉 Conclusion
The text-decoration-style
property is a versatile tool for web developers aiming to create distinctive text decorations.
By using different styles like solid, double, dotted, dashed, and wavy, you can enhance the visual appeal and readability of your text. Experiment with these styles to see how they can improve the aesthetics and user experience of your web projects.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (CSS text-decoration-style Property), please comment here. I will help you immediately.