×

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 Selector

CSS Selector: There are some selectors used in CSS, which allows us to choose the content we wish to style. Various selectors are considered as the separation of the set...

5 minutes read.

CSS Outline

CSS Outline: This CSS property is quite similar to the border property of CSS. It eases us to design an additional border around the element to obtain visual attention. The...

4 minutes read.

Css Box Model

Introduction The Box Model property of CSS is used for design and layout of an html page. In CSS, all the elements has a rectangular box around it, you have to...

5 minutes read.

CSS Introduction

CSS stands for Cascading Style Sheet. It is a design language which is used to design the web pages. It was developed by Håkon Wium Lie on October 10, 1994. It provides...

1 minute read.

CSS Overlay

CSS Overlay: It measures to cover-up something’s surface along with a coating. CSS overlay sets anything over the top area of other things. It creates a web-page more attractive. The...

8 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.

How to change font size in CSS

How to change font size in CSS? Font Size: - Users may attract attention to content on a website page in various ways. One element in a sentence can be highlighted. You...

5 minutes read.

Cascading Style Sheet

CSS refers to the Cascading Style Sheet. CSS is a form of a programming language. In other words, CSS is a language of the style sheet that is utilised for...

7 minutes read.

CSS Variables

CSS Variables These variables of CSS are applied to add the custom property values to our various web-pages. The custom properties are often called as CSS variables or cascading variables. Various...

4 minutes read.

CSS translate() Function

Translate() CSS function This function in CSS is a CSS in-built function. It relocates the element in the horizontal direction or in the vertical direction. It can move the items from...

2 minutes read.

How to edit CSS in WordPress

Developing a new website or blog is a difficult undertaking. We want to create something that the consumers will adore, but we might not want the setting to take months and...

7 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.

What is CSS

CSS stands for Cascading Style Sheet. It gives an additional style to the HTML document. A cascading style sheet is a language that is designed to define the document formatting...

3 minutes read.

Create a 3D text effect using HTML and CSS

A3D text effect is a beautiful and attractive part of a webpage. As a web page developer, it is crucial to know how to create a 3D text effect with...

3 minutes read.

How to change background color in CSS

How to change background color in CSS? The background-color property in CSS would be used to specify the color of an element's background. As the element's background, it uses solid colors. The...

3 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.

CSS Checkbox style

CSS Checkbox style: It is an element of HTML, which is used to get input from various users. It is difficult to style any checkbox. However, some elements make it...

6 minutes read.

CSS Sticky

CSS Sticky The position property in CSS is applied to set an element’s position. This property is also applied to position an element behind the other element. It is useful for...

1 minute read.

Difference between CSS Grid and CSS Flexbox

The way that information is arranged on a website reveals a lot about you or your company. Organizational abilities are just as important as having the right materials. The design...

3 minutes read.

How to include CSS

How to include CSS CSS is included in HTML pages for formatting the documents based on the information inside a style sheet. We can add CSS in HTML documents in the following three ways: Inline...

5 minutes read.