jQuery in Action
Selecting elements for manipulation
19
2.1.1 Using basic CSS selectors
For applying styles to page elements, web developers have become familiar with a 
small, but powerful and useful, group of selection methods that work across all
browsers. Those methods include selection by an element's
small, but powerful and useful, group of selection methods that work across all
browsers. Those methods include selection by an element's
ID
, 
CSS
 class name, 
tag name, and the 
DOM
 hierarchy of the page elements.
 Here are some examples to give you a quick refresher.
a
--This selector matches all link (
<a>
) elements.
#specialID
--This selector matches elements that have an id of 
specialID
.
.specialClass
--This selector matches elements that have the class of 
spe-
cialClass
.
a#specialID.specialClass
--This selector matches links with an id of 
spe-
cialID
 and a class of 
specialClass
.
p
a.specialClass
--This selector matches links with a class of 
specialClass
declared within 
<p>
 elements.
We can mix and match the basic selector types to select fairly fine-grained sets 
of elements. In fact, the most fancy and creative websites use some combination of
these basic options to create their dazzling displays.
of elements. In fact, the most fancy and creative websites use some combination of
these basic options to create their dazzling displays.
Figure 2.2  A selector value of 
li
 matches all 
<li>
 elements when applied as shown by the 
display results.