So lets say I have a class called
#links
And I want to modify links in a certain way ONLY in that class. Is there a way I can reference the “a” tag only in that class? I heard that “a.links” would work, but I can’t seem to make it.
So lets say I have a class called
#links
And I want to modify links in a certain way ONLY in that class. Is there a way I can reference the “a” tag only in that class? I heard that “a.links” would work, but I can’t seem to make it.
In the CSS you use the tag.class syntax.
In the HTML you use <a class=“myclassforanchor”> syntax
See CSS Syntax
You might be confusing classes with IDs. IDs are specified with #, and classes are specified with a dot. IDs should be unique in the document.
So, to select all the links of class “links” (which actually isn’t a very good class name, but nevermind that), use:
a.links { … }
k, thanks for the clarification.
So, if I want to use the hover property of links in my “links” div, I should say
a.links:hover
?
No, that would affect all <a class=“links”> tags, wherever they might be. To affect all the <a> tags that occur inside <div class=“links”>, use this:
div.links a:hover {
…
}
There are lots of good books out there on CSS that explain the selector rules a lot more clearly than the spec does. The selector rules are quite powerful, although some of the most powerful ones aren’t supported by the major browsers.