selector:pseudo-class {
property: value;
}
/* unvisited link */
a:link {
color: #FF0000;
}
/* visited link */
a:visited {
color: #00FF00;
}
/* mouse over link */
a:hover {
color: #FF00FF;
}
/* selected link */
a:active {
color: #0000FF;
}
Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective! a:active MUST come after a:hover in the CSS definition in order to be effective! Pseudo-class names are not case-sensitive.
a.highlight:hover {
color: #ff0000;
}
div:hover {
background-color: blue;
}
Example
p {
display: none;
background-color: yellow;
padding: 20px;
}
div:hover p {
display: block;
}
p:first-child {
color: blue;
}
p i:first-child {
color: blue;
}
p:first-child i {
color: blue;
}
<html>
<head>
<style>
q:lang(no) {
quotes: "~" "~";
}
</style>
</head>
<body>
<p>Some text <q lang="no">A quote in a paragraph</q> Some text.</p>
</body>
</html>
{
background-color: red;
}
</style>
<body>
<h1>This is a header.</h1>
<p>This is a paragraph.</p>
<a href="https://w3schools.com">This is a link.</a>
</body>
<style>
a:hover
{
background-color: red;
}
</style>
<body>
<h1>This is a header.</h1>
<p>This is a paragraph.</p>
<a href="https://w3schools.com">This is a link.</a>
</body>
10 videos|41 docs|23 tests
|
|
Explore Courses for Class 6 exam
|