|
* |
All elements |
|
|
div |
<div> |
|
|
div * |
All elements within <div> |
|
|
Contextual selectors |
One or more selectors delimited by spaces.The example rule indicates the bold markup will be red only while enclosed in H1 tags. |
H1 B {color: red;} |
|
Grouping |
One or more selectors separated by commas. Grouping allows you to assign styles to multiple elements (selectors). |
H1, H2, H3, H5 {color: purple;} |
|
div > span |
<span> with parent <div> |
|
|
div + span |
<span> preceded by <div> |
|
|
Class(tag attribute) |
Class selectors may be used as an attribute to a tag. A class selector is a string preceded by a period. Do not use the period when referencing the class. Do not begin a class name with a number, although IE4/5 let you get away with it. |
.example {color: red;} |
|
div.class |
<div> of class "class" |
|
|
#itemid |
Element with id "itemid" |
|
|
div#itemid |
<div> with id "itemid" |
|
|
a[attr] |
<a> with attribute "attr" |
|
|
a[attr='x'] |
<a> when "attr" is "x" |
|
|
a[class~='x'] |
<a> when class is a list containing 'x' |
|
|
a[lang|='en'] |
<a> when lang begins "en" |
|