
Originally Posted by
QuizToon
<p class="a:link right">link code</p>
<p class="a:link left">link code</p>
A class name is just an identifier that groups several 'types' of element. It doesn't resemble a selector. The class names you'd be looking for above is 'right' and 'left', respectively. However, class names should really reflect what that grouping represents, not how it appears.
Why do you have two columns? Is there any particular reason? For example, if the right-hand column contained external links (probably doesn't, but stay with me
), 'external-links' would be a much better class name than 'right'.
So, given:
HTML Code:
<p class="left"><a href="...">...</a></p>
you would select this in an external style sheet with:
Code:
p.left a {
/* Foreground and background colours should always
* be specified together. This is true even when the
* background colour may not change from the colour
* specified by ancestors. You can use the values
* transparent or inherit in cases like this.
*
* background-color: #rrggbb; */
color: #1a1fd6; /* Some random(-ish) dark blue */
}
You could select just the class itself by omitting the tag name:
Code:
.left a {
/* ... */
}
Notice that the dot (.) is still present. This signifies a class name. A hash (#) signifies an id.
Though this discussion has focused mainly on classes, they aren't always necessary. Selectors are mainly based on structure: ancestor-descendant relationships, mainly. A typical one is:
Code:
a img {
border-style: none;
}
which removes borders on all images that are contained within links.
Hope that helps,
Mike
Bookmarks