CSS Properties
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.
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
Value | Description |
---|---|
auto | The browser determines the thickness. |
from-font | Uses the thickness specified by the font (if supported). |
length | Specifies the thickness using a length value (e.g., 2px, 0.1em). |
percentage | Specifies 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.
<!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:
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-thickness Property), please comment here. I will help you immediately.