Open In App

CSS text-decoration-style Property

Last Updated : 28 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The CSS text-decoration-style property sets the style of text decoration, such as solid, double, dotted, dashed, or wavy lines. It works with text-decoration-line and text-decoration-color to customize text appearance, enhancing visual presentation and user experience on web pages.

Syntax

text-decoration-style: solid|double|dotted|dashed|wavy|initial|inherit;

Property Values

ValueDescription
solidDraws a solid single line. It is the default value of the text-decoration-style property.
doubleDraws double solid lines.
dottedDraws a dotted line.
dashedDraws a dashed line.
wavyDraws a wavy line.
initialSets the text-decoration-style property to its default value.
inheritInherits the property from its parent element.

Example 1: Solid Line

In this example, we demonstrate the text-decoration-style property with solid lines applied to underline, line-through, and overline text decorations on different paragraphs using CSS classes.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-decoration-style property
    </title>

    <!-- CSS style -->
    <style>
        p {
            text-decoration-style: solid;
        }

        .GFG1 {
            text-decoration-line: underline;
        }

        .GFG2 {
            text-decoration-line: line-through;
        }

        .GFG3 {
            text-decoration-line: overline;
        }
    </style>
</head>

<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <b>text-decoration-style: solid</b>

    <p class="GFG1">
        This line has a solid underline.
    </p>
    <p class="GFG2">
        This line has a solid line-through.
    </p>
    <p class="GFG3">
        This line has a solid overline.
    </p>
</body>

</html>

Output:

text-decoration-style-solid

Example 2: Double Line

In this example we use the text-decoration-style property with double lines applied to underline, line-through, and overline text decorations on different paragraphs using CSS classes.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-decoration-style property
    </title>

    <!-- CSS style -->
    <style>
        p {
            text-decoration-style: double;
        }

        .GFG1 {
            text-decoration-line: underline;
        }

        .GFG2 {
            text-decoration-line: line-through;
        }

        .GFG3 {
            text-decoration-line: overline;
        }
    </style>
</head>

<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <b>text-decoration-style: double</b>

    <p class="GFG1">
        This line has a double underline.
    </p>
    <p class="GFG2">
        This line has a double line-through.
    </p>
    <p class="GFG3">
        This line has a double overline.
    </p>
</body>

</html>

Output: text-decoration-style-double

Example 3: Dotted Line

In this example we use the text-decoration-style property with dotted lines applied to underline, line-through, and overline text decorations on different paragraphs using CSS classes.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-decoration-style property
    </title>

    <!-- CSS style -->
    <style>
        p {
            text-decoration-style: dotted;
        }

        .GFG1 {
            text-decoration-line: underline;
        }

        .GFG2 {
            text-decoration-line: line-through;
        }

        .GFG3 {
            text-decoration-line: overline;
        }
    </style>
</head>

<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <b>text-decoration-style: dotted</b>

    <p class="GFG1">
        This line has a dotted underline.
    </p>
    <p class="GFG2">
        This line has a dotted line-through.
    </p>
    <p class="GFG3">
        This line has a dotted overline.
    </p>
</body>

</html>

Output: text-decoration-style-dotted

Example 4: Dashed Line

In this example we use the text-decoration-style property with dashed lines applied to underline, line-through, and overline text decorations on different paragraphs using CSS classes.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-decoration-style property
    </title>

    <!-- CSS style -->
    <style>
        p {
            text-decoration-style: dashed;
        }

        .GFG1 {
            text-decoration-line: underline;
        }

        .GFG2 {
            text-decoration-line: line-through;
        }

        .GFG3 {
            text-decoration-line: overline;
        }
    </style>
</head>

<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <b>text-decoration-style: dashed</b>

    <p class="GFG1">
        This line has a dashed underline.
    </p>
    <p class="GFG2">
        This line has a dashed line-through.
    </p>
    <p class="GFG3">
        This line has a dashed overline.
    </p>
</body>

</html>

Output: text-decoration-style-dashed

Example 5: Wavy Line

In this example we are using the text-decoration-style property with wavy lines applied to underline, line-through, and overline text decorations on different paragraphs using CSS classes.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-decoration-style property
    </title>

    <!-- CSS style -->
    <style>
        p {
            text-decoration-style: wavy;
        }

        .GFG1 {
            text-decoration-line: underline;
        }

        .GFG2 {
            text-decoration-line: line-through;
        }

        .GFG3 {
            text-decoration-line: overline;
        }
    </style>
</head>

<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <b>text-decoration-style: wavy</b>

    <p class="GFG1">
        This line has a wavy underline.
    </p>
    <p class="GFG2">
        This line has a wavy line-through.
    </p>
    <p class="GFG3">
        This line has a wavy overline.
    </p>
</body>

</html>

Output: text-decoration-style-wavyExample 6: Initial Value

In this example we are using the text-decoration-style property set to initial, applying default styles to underline, line-through, and overline text decorations on different paragraphs using CSS classes.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-decoration-style property
    </title>

    <!-- CSS style -->
    <style>
        p {
            text-decoration-style: initial;
        }

        .GFG1 {
            text-decoration-line: underline;
        }

        .GFG2 {
            text-decoration-line: line-through;
        }

        .GFG3 {
            text-decoration-line: overline;
        }
    </style>
</head>

<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <b>text-decoration-style: initial</b>

    <p class="GFG1">
        This line has a default underline.
    </p>
    <p class="GFG2">
        This line has a default line-through.
    </p>
    <p class="GFG3">
        This line has a default overline.
    </p>
</body>

</html>

Output: text-decoration-style-initial

Example 7: Inherited Value

In this example we are using the text-decoration-style property set to inherit, applying wavy underline, line-through, and overline text decorations inherited from a parent div with the main class.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-decoration-style property
    </title>

    <!-- CSS style -->
    <style>
        p {
            text-decoration-style: inherit;
        }

        .main {
            text-decoration-style: wavy;
        }

        .GFG1 {
            text-decoration-line: underline;
        }

        .GFG2 {
            text-decoration-line: line-through;
        }

        .GFG3 {
            text-decoration-line: overline;
        }
    </style>
</head>

<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>

    <b>text-decoration-style: inherit</b>

    <div class="main">
        <p class="GFG1">
            This line has a inherited underline style.
        </p>
        <p class="GFG2">
            This line has a inherited line-through style.
        </p>
        <p class="GFG3">
            This line has a inherited overline style.
        </p>
    </div>
</body>

</html>

Output: text-decoration-style-inherit

The text-decoration-style property in CSS enhances the visual presentation of text by offering styles such as solid, double, dotted, dashed, and wavy. Proper application improves site aesthetics and user experience. Experiment with styles and ensure browser compatibility for consistent design across platforms.

Supported Browsers: The browser supported by text-decoration-style property are listed below:



Next Article

Similar Reads

  翻译: