How to Implement Text Decoration Using CSS

Published on Aug 22,2019 819 Views

How to Implement Text Decoration Using CSS

edureka.co

Underlining a document or a text is always considered easy. But if we consider the case for the websites, is it easy yet? Most of us would say yes but making a horizontal line including some custom designs make this simple task tiresome. Let start the Journey of Text Decoration Using CSS in the following manner:

 

What is Text Decoration?

It sets the appearance of the decorative lines on text. It is a shorthand property for:

It is specified as one or more space-separated values representing the long-hand text-decoration properties.

Syntax:

text-decoration : <'text-decoration-line'> || <'text-decoration-style'> || <'text-decoration-color'>

Where,

 

Types of Text Decorations in CSS

#decoration
{
text-decoration: overline;
}

 


#decoration
{
text-decoration: line-through;
}


#decoration
{
text-decoration: underline;
}

 


#decoration
{
text-decoration: underline line-through overline;
}

Output:

 

 

Text Decoration Using CSS : Code

HTML Code:


<center>
<h1 id="overline">A quick brown fox jumps over the lazy dog</h1>
<h1 id="underover">A quick brown fox jumps over the lazy dog</h1>
<h1 id="dotted">A quick brown fox jumps over the lazy dog</h1>
<h1 id="wavy">A quick brown fox jumps over the lazy dog</h1>
</center>

 

CSS Code:


#overline
{
text-decoration: wavy overline lime;
}
#underover
{
text-decoration: dashed underline overline;
}
#dotted
{
text-decoration: underline overline dotted red;
}
#wavy
{
text-decoration: line-through wavy;}

 

Output:

 

 

Text Decoration Skip

A property known as text-decoration-skip can also be used where a text overline, line-through and underline. It helps in decorating the text. It simply specifies how overline and underline are drawn when they pass over ascenders and descenders.


#decoration
{
text-decoration-skip: ink;
}

 

Values which can be used with text-decoration skips are:

 

Since this property is not supported by any browser yet there’s no demo, but here’s an example in the image below of how each of the values could look once text-decoration-skip is implemented.

 

With this, we come to the end of this  Text Decoration Using CSS blog. If you have any queries regarding this topic, please leave a comment below and we’ll get back to you.

Check out our Full Stack Web Developer Masters Program which comes with instructor-led live training and real-life project experience. This training makes you proficient in skills to work with back-end and front-end web technologies. It includes training on Web Development, jQuery, Angular, NodeJS, ExpressJS, and MongoDB.

Got a question for us? Please mention it in the comments section of “Text Decoration using CSS” blog and we will get back to you.

Upcoming Batches For Full Stack Web Development Course
Course NameDateDetails
Full Stack Web Development Course

Class Starts on 30th November,2024

30th November

SAT&SUN (Weekend Batch)
View Details
BROWSE COURSES