i have a href with class="button"
I am trying to style this like that:
.button a:link {text-decoration: none}
.button a:visited {text-decoration: none}
.button a:active {text-decoration: none}
.button a:hover {text-decoration: none; background-color:yellow;color:blue}
why it is not working?
how to set stye for a href with that class (class="button"
)
Hyperlinks can be styled in many different ways, of course, the color, font-family, background etc. properties do work for links, but they can also be styled according to the state that they are in.
To change the color of links in HTML, use the CSS property color. Use it with the style attribute. The style attribute specifies an inline style for an element. Use the style attribute with the CSS property color to change the link color.
.button a
is a descendant selector. It matches all <a>
tags that are descendants of .button
.
You need to write a.button:link
to match tags that are both <a>
and .button
.
.button a{}
is a rule for
<something class="button">
<a href="">foobar</a>
</something>
a.button{}
is a rule for
<a href="" class="button">foobar</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With