Browsers apply default styles to links:
:link — normal, unvisited links:visited — links the user has already visited:active — links when clicked/activatedExample CSS for each state:
a:link {
color: blue;
text-decoration: underline;
}
a:visited {
color: purple;
}
a:active {
color: red;
}Note: :link, :visited, and :active are Pseudo Elements
Style different link states using pseudo-classes:
:link – Unvisited link:visited – Visited link:hover – When hovered:active – While being clickeda:hover {
color: green;
}To remove the underline from links, use:
a {
text-decoration: none;
}Enhance user experience with color or font changes on hover:
a:hover {
color: red;
font-weight: bold;
}Add smooth animations using transition:
a {
color: navy;
transition: color 0.3s ease;
}
a:hover {
color: orange;
}Create three links with the following behavior:
<a href="#">Default Link</a>
<a href="#" style={{
textDecoration: "none",
color: "black"
}} onMouseOver={(e) => e.currentTarget.style.color = "green"}
onMouseOut={(e) => e.currentTarget.style.color = "black"}>
Hover Styled Link
</a>
<a href="#" style={{
color: "black",
transition: "color 0.3s ease"
}} onMouseOver={(e) => e.currentTarget.style.color = "orange"}
onMouseOut={(e) => e.currentTarget.style.color = "black"}>
Smooth Transition Link
</a>You can copy and paste this code in your IDE to run!
Ask the AI if you need help understanding or want to dive deeper in any topic