CSS Selectors
Selectors choose which elements a rule applies to.
31 of 31
| Name | Description |
|---|---|
| .class | Selects elements with a class. |
| #id | Selects the element with an id. |
| * | Selects every element. |
| element | Selects all elements of a type. |
| element, element | Selects all listed elements. |
| element element | Selects descendants. |
| element > element | Selects direct children. |
| element + element | Selects the next sibling. |
| element ~ element | Selects following siblings. |
| [attribute] | Selects elements that have an attribute. |
| [attribute=value] | Selects elements with an exact attribute value. |
| [attribute^=value] | Attribute starts with value. |
| [attribute$=value] | Attribute ends with value. |
| :hover | Selects an element under the mouse. |
| :focus | Selects the focused element. |
| :active | Selects an element being pressed. |
| :first-child | Selects the first child of its parent. |
| :last-child | Selects the last child. |
| :nth-child(n) | Selects children by position. |
| :not(selector) | Selects elements that do not match. |
| :checked | Selects checked inputs. |
| :disabled | Selects disabled controls. |
| :root | Selects the document root (html). |
| :is(a, b) | Matches any selector in the list. |
| :has(selector) | Selects an element that contains a match. |
| ::before | Inserts content before an element. |
| ::after | Inserts content after an element. |
| ::first-letter | Styles the first letter. |
| ::first-line | Styles the first line. |
| ::selection | Styles selected text. |
| ::placeholder | Styles placeholder text. |