user1341808 user1341808 - 1 month ago 6x
CSS Question

class for link not working with CSS

I've assigned the class "greenbutton" to a link in my html, but none of the changes I make to this class on my CSS take effect.


<p><a class="greenbutton" href="#">Sign Up</a> to learn more</p>


.greenbutton a:link, .greenbutton a:visited {
font-size: 14px;
text-decoration: none;

The weird thing about this is that when I assign this class to the preceding paragraph tag, the changes take effect. Any thoughts?


The CSS you're trying should either be applied to the <p> or modified to a.greenbutton. What you're specifying is an anchor within an element classed greenbutton. e.g.

.greenbutton a { } /* anchor inside .greenbutton-classed element, like:

  <p class="greenbutton">
    <a href="#">Foo</a>


a.greenbutton { } /* anchor with .greenbutton class applied, like:

  <a href="#" class="greenbutton">Bar</a>