Computer >> Computer tutorials >  >> Programming >> CSS

Text Decoration in CSS


For text decoration in CSS, use the text-decoration property as a shorthand property for the following properties −

text-decoration-line
text-decoration-color
text-decoration-style

Example

Let us see an example for text decoration in CSS −

<!DOCTYPE html>
<html>
<head>
<style>
.demo {
   text-decoration: overline underline;
}
</style>
</head>
<body>
<h1>Details</h1>
<p class="demo">Examination Center near ABC College.</p>
<p class="demo2">Exam begins at 9AM.</p>
</body>
</html>

Output

Text Decoration in CSS

Example

Let us now see another example wherein we are using separate values −

<!DOCTYPE html>
<html>
<head>
<style>
p {
   writing-mode: vertical-rl;
   text-decoration-line: overline;
   text-decoration-color: red;
   text-decoration-style: wavy;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<p>This is demo text.</p>
</body>
</html>

Output

Text Decoration in CSS