Combining Selectors

Combining Selectors

You can combine any of the techniques that I've explained in the last few pages in order to pinpoint the elements that you're interested in formatting.

To combine selectors:

Define the context of the desired element. For more details, consult Selecting Elements by Context on page 141.

Next, either spell out the element's name (see page 139) or use the wild card character (see page 139).

Then, specify the class or id of the desired element(s). For more details, consult Selecting Elements by ID or Class on page 140.

Next, specify the pseudo-class or pseudo-element. For more details, consult Selecting Part of an Element on page 144 and Selecting Link Elements Based on Their State on page 146.

Finally, specify which attributes and values must be present for the element to be selected. For more details, consult Selecting Elements Based on Attributes on page 147.

Figure. Here's a doozy for you. It says "choose only the first letter of the em elements that are found within p elements that are in the div elements whose class is equal to works.


  • You may leave out any of the steps that you don't need. This page is designed to show you the order in which the different criteria should be listed.

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows