Home > Back-end >  declaring link attributes inside a class in css
declaring link attributes inside a class in css

Time:12-19

Why is the second link not yellow? There is the class myclass and there is declared every link's color inside the class to be yellow. However, it is blue.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>hey I am a title</title>
    <style>
a:link,
a:hover,
a:visited,
a:active {
    color: blue;
    text-decoration: underline;
}

a.myclass:link,
a.myclass:hover,
a.myclass:visited,
a.myclass:active {
    color: yellow;
    text-decoration: underline;
}
    </style>
</head>
<body>

<a href="indexde.htm">first link</a>

<br><br>

<span >
    <a href="indexde.htm">second link</a>
</span>

</body>
</html>

CodePudding user response:

Change

a.myclass:link,
a.myclass:hover,
a.myclass:visited,
a.myclass:active {
    color: yellow;
    text-decoration: underline;
}

to

.myclass a:link,
.myclass a:hover,
.myclass a:visited,
.myclass a:active {
    color: yellow;
    text-decoration: underline;
}
  •  Tags:  
  • css
  • Related