EN
CSS - text underline on hover
0 points
In this article, we would like to show you how to underline text on hover event using CSS.
Quick solution:
xxxxxxxxxx
1
div:hover {
2
text-decoration: underline;
3
}
The :hover
CSS pseudo-class is triggered when the user hovers over an element with the cursor, changing the element style to the one specified within curly brackets.
In this example, we add on-hover text underline to the div
element using div:hover
pseudo-class with text-decoration
property set to underline
.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
div:hover {
7
text-decoration: underline;
8
}
9
10
</style>
11
</head>
12
<body>
13
<div>Hover me to underline.</div>
14
</body>
15
</html>