Reference
Selector | Description | Use |
---|---|---|
* {} | Universal selector | Applies to all elements in the document |
h1, h2 {} | Type selector | Matches element names |
.class {} p.class {} |
Class selector |
Matches an element whose class attribute matches that after the
period If there is an element before the period, matches only those elements with that class |
#id {} | ID selector | Matches an element whose ID matches that after the # |
li>a {} | Child selector | Matches an element that is a direct child of another |
li a {} | Descendant selector | Matches an element that sits inside another element, even if other elements nested between them |
h1+p {} | Adjacent sibling selector | Matches an element that is the next sibling of another (first <p> after any <h1> element) |
h1~p {} | General sibling selector | Matches an element that is a sibling of another (would apply to all <p> elements that are siblings of an <h1> element |