外观
Selector Type
Example
Note
Universal selector
*
/
Type selectors
b
div,p select all <div> elements and all <p> elements.
Class selectors
.classname
/
ID selectors
#idname
/
Descendant selectors
span em
Select all <em> elements who have a parent element of <span>.
Child selectors
div > em
Select all <em> elements who have a direct parent element of <div>
Adjacent sibling selectors
i + b
Select the <b> element who is directly after the <i> element, and meanwhile both the <i> and <b> elements should be within a same parent element.
Attribute selectors
a[href='info.htm']
/
Pseudoclasses
a:hover
/
Pseudoelements
p::first-letter
/