- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Text Decoration Using CSS
The CSS text-decoration property is used to apply decoration to selected element’s text. We can add a line-through, overline, underline, etc. as values. It is a shorthand for text-decoration-line, text-decoration-color and text-decoration-style.
Syntax
The syntax of text-decoration property is as follows −
Selector { text-decoration: /*value*/ }
Example
The following examples illustrate CSS text-decoration property −
<!DOCTYPE html> <html> <head> <style> p:nth-child(2)::before { content: " We will reach the destination "; background-color: lightgreen; text-decoration: overline blue; font-size: 1.2em; } </style> </head> <body> <p>I'm not the only traveller</p> <p> before night. </p> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html> <head> <style> span { background: rgb(204,22,50); text-decoration: blue line-through; font-style: italic; color: white; } p { text-decoration: underline; } </style> </head> <body> <h2>Department Details</h2> <p> The employees of Department Marketing, Operations, Finance, <span>IT</span> are requested to email their original documents.<span> Delay in submission will lead to delayed verification.</span> </p> </body> </html>
Output
This gives the following output −
- Related Articles
- Text Decoration in CSS
- Animate CSS text-decoration-color property
- Usage of text-decoration property in CSS
- How to Change Link Underline Color using text-decoration-color CSS
- Set the color of the text decoration in CSS
- Set the style of the text decoration in CSS
- Set the kind of decoration used on text in CSS
- Formatting Text Using CSS
- Text Transformation using CSS
- Text Indentation using CSS
- Setting Text Color using CSS
- Set Text Alignment using CSS
- Setting Text Alignment using CSS
- How to set the decoration of a text with JavaScript?
- How to Justify Text using text-align & text-justify CSS Properties?

Advertisements