HTML and CSS Reference
In-Depth Information
Table 2-1. Basic CSS Selectors Supported by Most Current Browsers
Pattern/Selector
Name
Meaning
*
Universal selector
Matches any element.
E
Matches any HTML element of type E . he
selector consists of the HTML tag name without
the angle brackets. For example, h1 selects all
<h1> tags.
Type selector
.className
Matches elements with the class attribute
className .
Class
#someId
Matches elements with the id attribute someId .
ID selector
E:link
Matches elements of type E if E is an unvisited
link.
Link pseudo-class
E:visited
Matches elements of type E if E is a visited link.
Visited pseudo-class
E:hover
Matches elements of type E when the cursor is
hovering over it. IE 6 supports this only on links.
Other browsers support it on all elements.
Hover pseudo-class
E:active
Matches elements of type E at the moment the
element is being clicked. IE 6 and IE 7 support
this only on links.
Active pseudo-class
E:focus
Matches elements of type E when the element
currently has focus. Not supported by IE 6 or IE 7.
Focus pseudo-class
E:first-letter
Matches the first letter of element E .
First-letter pseudo-element
E:first-line
Matches the first line of element E .
First-line pseudo-element
E F
Matches any F element that is a descendant of an
E element.
Descendant selector
E[attr]
Matches elements of type E with the attribute
attr .
Attribute selector
E[attr= "x"]
Matches elements of type E where the value of
the attr attribute is exactly "x" .
Attribute selector
E[attr^= "x"]
Matches elements of type E where the value of
the attr attribute begins with "x" .
Attribute selector
E[attr$= "x"]
Matches elements of type E where the value of
the attr attribute ends with "x" .
Attribute selector
Universal Selector
he universal selector is represented by an asterisk ( * ). It selects any element, but is rarely used except to create
hacks to hide styles from IE 6.
 
 
Search WWH ::




Custom Search