Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS text-decoration-style Property

Posted in CSS Tutorial
Updated on Oct 13, 2024
By Mari Selvan
👁️ 12 - Views
⏳ 4 mins
💬 1 Comment
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.

Syntax
Copied
Copy To Clipboard
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

ValueDescription
solidA solid line.
doubleTwo parallel solid lines.
dottedA dotted line.
dashedA dashed line.
wavyA wavy line.

📄 Example

In this example, we'll apply different text-decoration styles to various text elements.

index.html
Copied
Copy To Clipboard
<!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:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

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

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy