×

CSS Text-decoration

CSS Text-decoration: It is an essential property of CSS that is used to decorate the content of the text. It can add-on the lines above, under, and over the text. This property sets the presentation of the decorative line over the text.

 It illuminates the text along with various types of lines. It is used for text-decoration-style, text-decoration-color, and text-decoration-line.

The syntax is as follows for this property:

Syntax:

text-decoration: text-decoration-line text-decoration-color text-decoration-style|initial|inherit;  

Let’s understand its values with the help of an example:

  • text-decoration-line

It is used to do text-decoration of various kinds like underline, overline, or line-through. Also, it can add the line combination for any selected text.

Example:

In the following example, we are using the line-through, underline, or overline values. We will also understand how we can simultaneously apply these values.

<!DOCTYPE html>
<html>
<head>
<title> CSS text-decoration </title>
<style>
h1
{
 color: pink;
}
h2
{
 color: lime;
}
body
{
 text-align: center;
}
p
{
 font-size: 30px;
}
.p1
{
 text-decoration: underline;
}
.p2
{
 text-decoration: line-through;
}
.p3
{
 text-decoration: overline;
}
.p4
{
 text-decoration: overline underline line-through;
}
</style>
</head>
<body>
<h1> Welcome to this Page </h1>
<h2> text-decoration: text-decoration-line; </h2>
<div>
<p class= "p1"> It is underline </p>
<p class= "p2"> It is line-through </p>
<p class= "p3"> It is overline </p>
<p class= "p4"> It is a combination of the lines </p>
</div>
</body>
</html>

Output:

CSS Text-decoration
  • text-decoration-style

This CSS values sets the line’s style. Some of its values are dotted, double, dashed, solid, and wavy.

Consider the following illustration:

Example:

<!DOCTYPE html>
<html>
<head>
<title> CSS text-decoration </title>
<style>
h1
{
 color: red;
}
h2
{
 color: lime;
}
body
{
 text-align: center;
}
p
{
 font-size: 30px;
}
.p1
{
 text-decoration: underline double;
}
.p2
{
 text-decoration: line-through dashed;
}
.p3
{
 text-decoration: dotted overline;
}
.p4
{
 text-decoration: pink wavy overline underline line-through;
 color: navy;
}
</style>
</head>
<body>
<h1> Welcome to this Page </h1>
<h2> text-decoration: text-decoration-line text-decoration-style; </h2>
<div>
<p class= "p1"> It is double underline </p>
<p class= "p2"> It is dashed line-through </p>
<p class= "p3"> It is dotted overline </p>
<p class= "p4"> It is a wavy combination of the lines </p>
</div>
</body>
</html>

Output:

CSS Text-decoration
  • text-decoration-color

This CSS property is applied to give a lot of decoration colors. We can use any color, but in the valid format as its values.

Example:

<!DOCTYPE html>
<html>
<head>
<title> CSS text-decoration </title>
<style>
h1
{
 color: red;
}
h2
{
 color: lime;
}
body
{
 text-align: center;
}
p
{
 font-size: 30px;
}
.p1
{
 text-decoration: underline double violet;
}
.p2
{
 text-decoration: line-through dashed lime;
}
.p3
{
 text-decoration: dotted overline blue;
}
.p4
{
 text-decoration: pink wavy overline underline line-through;
 color: navy;
}
</style>
</head>
<body>
<h1> Welcome to this Page </h1>
<h2> text-decoration: text-decoration-line text-decoration-style text-decoration-color; </h2>
<div>
<p class= "p1"> It is underline violet </p>
<p class= "p2"> It is dashed line-through lime </p>
<p class= "p3"> It is dotted overline navy</p>
<p class= "p4"> It is a wavy combination of the lines pink </p>
</div>
</body>
</html>

Output:

CSS Text-decoration

Related Topics

CSS Page-break-after Attribute

Page-break-after Attribute As its name implies, the page-break-before property is applied to include page break after any element, at the time of printing a document. It adds the page break after...

5 minutes read.

CSS Overflow

CSS Overflow: The Overflow property in CSS is used to manage the content if it overflows from its container of the block level. We have seen that all the elements...

3 minutes read.

CSS Font-Size

A Cascading Style Sheet (CSS) is a simple design scripting language intended to simplify the process of making web pages more visually appealing with the kind of high-level formatting. Cascading...

3 minutes read.

CSS Letter-spacing

CSS Letter-spacing: Letter-spacing attribute is applied to manage the space among all letters within the block or element of the text. This property sets the behavior of the spacing between...

2 minutes read.

CSS Color Keywords

Here, we will discuss the following keywords: transparent currentcolor Inherit Transparent keyword A color can generally be made transparent by using the transparent keyword. Often it is used to for all intents...

4 minutes read.

CSS Transition

CSS Transition The transitions in CSS are influenced, included to modify the component from one design to another, without the use of the JavaScript or Flash. We should describe two of the...

2 minutes read.

CSS: nth-selector

CSS nth selector can be used to match an element according to its position regardless of its parent’s type. Here, n can be any number, formula, or a keyword. These selectors...

2 minutes read.

CSS Page-break-before Attribute

Page-break-before Attribute As its name implies, the page-break-before property is applied to include page break before any element, at the time of printing any document. It adds the page break before...

5 minutes read.

What is a CSS File?

What is a CSS File and How to use it in Html? CSS: - CSS stands for Cascading Style Sheet. CSS is a file of style sheets that describe the presentation of...

4 minutes read.

CSS Counters

CSS Counters: The CSS counter property is similar to the variables. CSS counters are controlled via CSS, and its values are incremented via rules of CSS to record how much...

4 minutes read.

CSS Math Functions

The CSS math functions permit numerical articulations. These CSS math functions can particularly be utilized in maybe unforeseen ways, for example, inside angles and shading the functions and in the...

3 minutes read.

CSS Gradient

CSS Gradient: The CSS gradient property is applied to show the smooth transition inside two specified colors or more than two specified colors. Need of CSS Gradient The following are a few...

4 minutes read.

CSS Arrow

CSS Arrow The arrow of CSS is applied to insert an array with the tooltip. It can make a tooltip as any speech bubble. Also, this arrow can be illustrated in...

4 minutes read.

CSS :root selector

CSS :root selector This CSS pseudo-class matches any document’s root element. It chooses the parent of the highest-level inside the document DOM or tree. An element of <html> is always a...

2 minutes read.

CSS Vertical Align

Vertical Align The vertical align CSS property describes the cell box of the table and an inline alignment vertically. This property is a self-explanatory and an essential property in CSS. But,...

2 minutes read.

How to change the font in CSS

How to change the font in CSS? Professionals can't deny typefaces — how users organize and style text — if we want to completely customize the website's design. One may wish...

4 minutes read.

CSS Syntax

The CSS syntax contains the selector and the declaration block, which will be clearer with the following example: Selector: A CSS selector specifies the HTML tag we wish to style. A selector can be...

2 minutes read.

Grid Vs Flexbox in CSS

Grid: - CSS Grid Layout is a 2D grid-based matrix-based layout method with columns and rows that simplifies web pages created by eliminating the need for floats and placement. A grid layout, like...

4 minutes read.

CSS Text-Overflow

Introduction: The text-overflow property of CSS is used to format the text which is overflowing the boundaries of the container. This property helps user to clip the text, to display the...

5 minutes read.

CSS Links

CSS Link is used to create styled link. There are various ways to implement it. Styling Links Link can be styled with CSS properties like color, font-family, background etc. Example: <!DOCTYPE html>   <html>   <head>   <style>   a {       color: red;   }   </style>   </head>   <body>   <p><b><a href="https://www.tutorialandexample.com"    target="_blank">This is a link</a></b></p>   </body>   </html> Try Now There are four...

2 minutes read.