In HTML, you can change the color of links using CSS. The default color for links is usually blue, but you can change it to any color you want.
To change the color of all links on a web page, you can use the a
selector in your CSS. Here’s an example:
a {
color: red;
}
In this example, all links on the page will be displayed in red.
You can also change the color of different types of links using CSS. For example, you can change the color of unvisited links, visited links, and links that are being hovered over by the mouse cursor. Here’s an example:
a:link {
color: blue;
}
a:visited {
color: purple;
}
a:hover {
color: green;
}
In this example, unvisited links will be displayed in blue, visited links will be displayed in purple, and links that are being hovered over will be displayed in green. The order of the CSS selectors is important because the browser applies the styles in the order they are defined.
You can also use CSS classes to apply different styles to specific links on a web page. Here’s an example:
<a href="#" class="link-style-1">Link 1</a>
<a href="#" class="link-style-2">Link 2</a>
.link-style-1 {
color: red;
}
.link-style-2 {
color: green;
}
In this example, the first link will be displayed in red because it has the link-style-1
class, and the second link will be displayed in green because it has the link-style-2
class.