×

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

CSS Lists: Several properties are available in CSS that are used to manage the lists. Lists are distributed as ordered and unordered kind of lists. The ordered lists provide the...

7 minutes read.

CSS Reference

The CSS Reference lists all of the basic standard CSS properties, pseudo-classes, pseudo-elements, and data types, for all intents and purposes functional notations, and at-rules alphabetically.  The site also includes...

5 minutes read.

CSS Image Gallery

Image galleries are used to display and store collections of images. Example Let’s discuss an example. CSS was used to create the following image gallery: Code is as follows: <html> <head> <style> div.gallery {   margin: 6px;   border: 1px...

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 @keyframes rule

CSS @keyframes rule It describes the rule of animation that depicts the properties of CSS for the components at every state along with the timeline. We may make the properties of complex...

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

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 Animation

CSS Animation: The animation property of CSS is applied to make animation over any webpage. It is used as the animation replacement made by JavaScript and Flash. Rules of CSS3 @keyframes The...

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

Divi in CSS

Divi is popular WordPress themes due to its versatility and user-friendly interface. It includes a built-in page builder for sophisticated design options and an assortment of customization features to help...

9 minutes read.

CSS Padding

CSS Padding: The padding property in CSS is addressed to describe the space among the element border and the element content.This property is quite different from the margin property of...

2 minutes read.

How to create blinking text using CSS

The blinking effect is used in HTML and CSS to take the attraction towards a particular word or section. If you need such a blinking effect, we need to take...

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

How to make smooth bounce animation using CSS

The smooth bouncing animation project is done with the help of HTML and CSS. This project gives so much fun and excitement to the users. What is HTML? The HTML or HyperText...

2 minutes read.

Untitled Reusable Block

  ...

1 minute 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 Background-clip

CSS Background-clip: The background-clip property describes the background’s painting area. It limits an area where the image or color of the background appears by using any clipping box. Everything will...

2 minutes read.

CSS Comments

CSS Comments: Generally, comments in CSS are used to describe our code. Further, it will provide support to many users who are concerned with the code. Somewhat, these are ignored...

2 minutes read.

CSS White Space Property

White Space in CSS The white-space CSS property describes how to show the content inside an element. This property is applied to manage a white space within an element. Values of White-space...

2 minutes read.