Open In App

CSS text-decoration-thickness Property

In this article, we will discuss the text-decoration-thickness property in CSS. 

This property sets the width of the stroke of the decorated line below, above, or through the text. The different values that this option can take are as follows:



Syntax:

text-decoration-thickness: auto | font-file | length | percentage | global values;

In the following examples, we have 4 different paragraphs with different classes of auto, font-file, length, percentage. For each of the classes, we have provided the different values and the style is applied accordingly. 



Example 1: This example demonstrates the use of text-decoration-thickness with the value of the auto




<!DOCTYPE html>
<html>
<head>
    <title>text-underline-offset property in CSS</title>
    <style>
        .auto {
            text-decoration-thickness: auto;
            text-decoration-line: solid;
            text-decoration-line: underline;
            text-decoration-color: green;
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h2 style="color:green;text-align:center;">
       GeeksforGeeks
    </h2>
    <p style="text-align:center;">
       text-decoration-thickness:auto
    </p>
 
 
    <p class="auto">
       A computer science portal for geeks.
    </p>
 
    
</body>
</html>

Output:

Example 2: This example demonstrates the use of the text-decoration-thickness property with the value of the auto. In this case, the output is the same since the auto sets the font-file values and so it becomes the default.




<!DOCTYPE html>
<html>
 
<head>
    <title>text-underline-offset property in CSS</title>
    <style>
        .font-file {
            text-decoration-thickness: font-file;
            text-decoration-line: solid;
            text-decoration-line: underline;
            text-decoration-color: green;
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h2 style="color:green;text-align:center;">
       GeeksforGeeks
    </h2>
    <p style="text-align:center;">
       text-decoration-thickness:font-file
    </p>
 
 
    <p class="font-file">
       A computer science portal for geeks.
    </p>
 
    
</body>
</html>

Output:

Example 3: This example demonstrates the text-decoration-thickness property set with a defined length of 3px.




<!DOCTYPE html>
<html>
 
<head>
    <title>text-underline-offset property in CSS</title>
    <style>
        .length {
            text-decoration-thickness: 3px;
            text-decoration-line: solid;
            text-decoration-line: underline;
            text-decoration-color: green;
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h2 style="color:green;text-align:center;">
       GeeksforGeeks
    </h2>
    <p style="text-align:center;">
       text-decoration-thickness:length
    </p>
 
 
    <p class="length">
       A computer science portal for geeks.
    </p>
 
    
</body>
</html>

Output:

Example 4: This example demonstrates the text-decoration-thickness property set with a defined percentage of 12%.




<!DOCTYPE html>
<html>
 
<head>
    <title>text-underline-offset property in CSS</title>
    <style>
        .percentage {
            text-decoration-thickness: 12%;
            text-decoration-line: solid;
            text-decoration-line: underline;
            text-decoration-color: green;
            text-align: center;
        }
    </style>
</head>
<body>
    <h2 style="color:green;text-align:center;">
       GeeksforGeeks
    </h2>
    <p style="text-align:center;">
       text-decoration-thickness:percentage
    </p>
 
 
    <p class="percentage">
       A computer science portal for geeks.
    </p>
 
    
</body>
</html>

Output:

Example 5: This example demonstrates the text-decoration-thickness property set with the initial value. It is used to set an element’s CSS property to its default value. It is the same as none property.




<!DOCTYPE html>
<html>
 
<head>
    <title>text-underline-offset property in CSS</title>
    <style>
        .initial {
            text-decoration-thickness: initial;
            text-decoration-line: solid;
            text-decoration-line: underline;
            text-decoration-color: green;
            text-align: center;
        }
    </style>
</head>
<body>
    <h2 style="color:green;text-align:center;">
       GeeksforGeeks
    </h2>
    <p style="text-align:center;">
       text-decoration-thickness:initial
    </p>
 
 
    <p class="initial">
       A computer science portal for geeks.
    </p>
 
    
</body>
</html>

Output:

Example 6: This example demonstrates the text-decoration-thickness property set with the inherit value.




<!DOCTYPE html>
<html>
 
<head>
    <title>text-underline-offset property in CSS</title>
    <style>
        .inherit {
            text-decoration-thickness: inherit;
            text-decoration-line: solid;
            text-decoration-line: underline;
            text-decoration-color: green;
            text-align: center;
        }
    </style>
</head>
<body>
    <h2 style="color:green;text-align:center;">
       GeeksforGeeks
    </h2>
    <p style="text-align:center;">
       text-decoration-thickness:inherit
    </p>
 
 
    <p class="inherit">
       A computer science portal for geeks.
    </p>
 
    
</body>
</html>

Output:

Example 7: This example demonstrates the text-decoration-thickness property set with the unset value.




<!DOCTYPE html>
<html>
 
<head>
    <title>text-underline-offset property in CSS</title>
    <style>
        .unset {
            text-decoration-thickness: unset;
            text-decoration-line: solid;
            text-decoration-line: underline;
            text-decoration-color: green;
            text-align: center;
        }
    </style>
</head>
<body>
    <h2 style="color:green;text-align:center;">
       GeeksforGeeks
    </h2>
    <p style="text-align:center;">
       text-decoration-thickness:unset
    </p>
 
 
    <p class="unset">
       A computer science portal for geeks.
    </p>
 
    
</body>
</html>

Output:

Supported Browsers: Browsers supporting text-decoration-thickness property are listed below.


Article Tags :