07-26-2023, 07:14 PM
Example:
<!DOCTYPE html>
<html>
<head>
<title>Pseudo-classes Example</title>
<style>
/* Style the link when hovered */
a:hover {
color: red;
}
</style>
</head>
<body>
<a href="#">Hover over this link</a>
</body>
</html>
Explanation:
Pseudo-classes target elements based on their state or user interaction. In this example, the a:hover pseudo-class selects the anchor (<a>) element when the user hovers over it and applies a red color to the text. When you hover over the link, the text turns red.
<!DOCTYPE html>
<html>
<head>
<title>Pseudo-classes Example</title>
<style>
/* Style the link when hovered */
a:hover {
color: red;
}
</style>
</head>
<body>
<a href="#">Hover over this link</a>
</body>
</html>
Explanation:
Pseudo-classes target elements based on their state or user interaction. In this example, the a:hover pseudo-class selects the anchor (<a>) element when the user hovers over it and applies a red color to the text. When you hover over the link, the text turns red.