Reputation: 31
<html>
<body>
<a href="test.html" style="{color: blue; background: white} :visited {color: red} :hover {background: red} :visited:hover {color: red}">
Test
</a>
</body>
</html>
Why it's not possible to set a hover
attribute on this kind?
Upvotes: 0
Views: 2034
Reputation: 507
Look at code below and see if its what you mean, if so then try that.
.css
{
color: blue;
background: white;
}
.css:visited
{
color: red;
}
.css:hover
{
background: red;
}
.css:visited:hover
{
color: red;
}
<a href="test.html" class="css">Test</a>
Upvotes: 7
Reputation: 943661
Because :hover
is part of the selector and when you use a style
attribute you don't have a selector. The value of the style
attribute is, effectively, the body of a ruleset (the ruleset applies to the element that has the style
attribute instead of having a selector to describe where it applies).
Use a stylesheet if you want to use selectors. Don't use inline style attributes.
Upvotes: 2