user4042171
user4042171

Reputation: 31

HTML style individual hover color

<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

Answers (2)

Katler
Katler

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

Quentin
Quentin

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

Related Questions