#id |
#container |
Selects the element with id="container" |
.class |
.header |
Selects the element with class="header" |
element.class |
p.description |
Selects all <p> elements with class="description" |
element, element |
div, p |
Selects all <p> elements and all <div> elements |
element element |
div p |
Selects all <p> elements inside <div> elements |
element+element |
div + p |
Selects the first <p> element that is placed immediately after <div> element |
element>element |
div > p |
Selects all <p> elements where the parent is a <div> element |
element1~element2 |
p ~ ul |
Selects every <ul> element that is preceded by a <p> element |
:first-child |
p:first-child |
Selects every <p> element that is the first child of its parent |
:last-child |
p:last-child |
Selects every <p> element that is the last child of its parent |
:hover |
button:hover |
Selects the button on mouse hover |
* |
* |
Selects all elements |
[attribute] |
src |
Selects all elements with a src attribute |
[attribute=value] |
[target="_blank"] |
Selects all elements with target="_blank" |
::after |
p::after |
Insert something after the content of each <p> element |
::before |
p::before |
Insert something before the content of each <p> element |
:active |
a:active |
Selects the active link |
:visited |
a:visited |
Selects all visited links |
:link |
a:link |
Selects all unvisited links |
:checked |
input:checked |
Selects every checked <input> element |
:default |
input:default |
Selects the default <input> element |
:disabled |
input:disabled |
Selects every disabled <input> element |
:required |
input:required |
Selects input elements with the "required" attribute specified |
:not(selector) |
:not(p) |
Selects every element that is not a <p> element |
:last-of-type |
p:last-of-type |
Selects every <p> element that is the last <p> element of its parent |
:first-of-type |
p:first-of-type |
Selects every <p> element that is the first <p> element of its parent |