The a
element in HTML represents a hyperlink, and it is used to link one page to another. In CSS, you can use the a
selector to style the appearance of hyperlinks.
Here is an example of how to use the a
selector to style the appearance of hyperlinks:
a {
color: blue;
text-decoration: none;
}
a:hover {
color: red;
}
a:visited {
color: purple;
}
In this example, the a
selector sets the color of hyperlinks to blue and removes the text decoration. The a:hover
selector changes the color of the hyperlink to red when the mouse cursor is over the hyperlink. The a:visited
selector changes the color of the hyperlink to purple after the hyperlink has been visited.
You can also use the a
selector to style the appearance of hyperlinks in different states, such as a:active
, a:focus
, and a:target
.
a:active {
color: green;
}
a:focus {
outline: 2px solid orange;
}
a:target {
background-color: yellow;
}
a:active
selector changes the color of the hyperlink to green when the hyperlink is being clicked, the a:focus
selector adds an orange outline around the hyperlink when it has focus, and the a:target
selector changes the background color of the hyperlink to yellow when it is the target of the current page.
0 Comments