Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS text-decoration-thickness Property

Posted in CSS Tutorial
Updated on Jul 19, 2024
By Mari Selvan
👁️ 10 - Views
⏳ 4 mins
💬 1 Comment
CSS text-decoration-thickness Property

Photo Credit to CodeToFun

🙋 Introduction

The text-decoration-thickness property in CSS allows web developers to control the thickness of text decoration lines, such as underlines, overlines, and line-throughs.

This property provides more fine-grained control over the appearance of these decorations, allowing for better customization and design flexibility.

💡 Syntax

The syntax for the text-decoration-thickness property is straightforward. It can be applied to any text element, and you can specify the thickness using various units or keywords.

Syntax
Copied
Copy To Clipboard
element {
  text-decoration-thickness: value;
}

Here, value can be a length (e.g., 2px, 0.1em), a percentage, or a keyword.

🎛️ Default Value

The default value of the text-decoration-thickness property is auto, which means the thickness is determined by the browser and is typically based on the font size and type.

🏠 Property Values

ValueDescription
autoThe browser determines the thickness.
from-fontUses the thickness specified by the font (if supported).
lengthSpecifies the thickness using a length value (e.g., 2px, 0.1em).
percentageSpecifies the thickness as a percentage of the element's font size (e.g., 10%).

📄 Example

In this example, we'll set the thickness of the underline for a paragraph to 3px.

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-thickness Example</title>
  <style>
    p {
      text-decoration: underline;
      text-decoration-thickness: 3px;
    }
  </style>
</head>
<body>
  <h1>Paragraph with Custom Text Decoration Thickness</h1>
  <p>This is an example paragraph with a thick underline.</p>
</body>
</html>

🖥️ Browser Compatibility

The text-decoration-thickness 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-thickness property is a valuable addition to CSS, providing developers with greater control over text decoration aesthetics.

By customizing the thickness of text decoration lines, you can enhance the visual appeal and readability of your text. Experiment with different values to see how this property can improve your web designs.

👨‍💻 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