HTML and CSS Reference
In-Depth Information
Using traditional approaches, you would have to apply classes to each
element. For the previous three examples, the code would be some-
thing like the following, where the class names don't add any further
meaning to the markup—they just make explicit relationships that are
already present:
<table>
<tr class="odd">
<td></td>
</tr>
<tr class="even">
<td></td>
</tr>
</table>
<ul>
<li>
<a href="/home"
class="current">
Home
</a>
<a href="/other">
Other
</a>
</li>
</ul>
<ul>
<li class="first">
top + right border
</li>
<li>
right border
</li>
<li class="last">
bottom + right
border
</li>
</ul>
In CSS3 , thanks to all the new selectors available, you can take advan-
tage of those relationships directly with no need to add extra class attri-
butes. In this section, you'll learn about the key ways of selecting
elements with CSS combinators and pseudo-classes.
Selecting sets of elements with combinators
Combinators allow you to chain simple selectors together. They're the
workhorses of CSS . The following diagrams show a simple HTML
fragment as a tree structure and then highlight the elements that the
different rules select using the common CSS2 combinators.
Search WWH ::




Custom Search