:active | Selects the active link | a:active { color: red } |
:checked | Selects the checked element | input:checked { background-color: yellow } |
:disabled | Selects the disabled element | input:disabled { opacity: 0.5 } |
:empty | Selects elements that have no children | p:empty { display: none } |
:enabled | Selects the enabled element | input:enabled { border-color: green } |
:first-child | Selects the first child of an element | li:first-child { font-weight: bold } |
:focus | Selects the element that has focus | input:focus { border-color: blue } |
:hover | Selects the element that the user is hovering over | a:hover { text-decoration: underline } |
:lang | Selects elements with a specified language attribute | p:lang(en) { font-style: italic } |
:last-child | Selects the last child of an element | li:last-child { font-weight: bold } |
:not | Selects all elements that do not match a selector | :not(p) { margin-bottom: 10px } |
:nth-child | Selects elements based on their position among siblings | li:nth-child(odd) { background-color: lightgray } |
:nth-last-child | Selects elements based on their position among siblings, counting from the last child | li:nth-last-child(even) { background-color: lightgray } |
:only-child | Selects elements that are the only child of their parent | p:only-child { font-size: 24px } |
:root | Selects the root element of the document | :root { --main-color: red } |
:target | Selects the target element of an anchor link | #section1:target { background-color: yellow } |
:checked | Selects a radio button or checkbox that is checked | input[type="checkbox"]:checked { background-color: yellow } |
| | |
:default | Selects the default button in a form | button:default { border-color: blue } |
:dir() | Selects elements with a specified text direction | p:dir(ltr) { text-align: left } |
:drop | Selects elements that are being dragged | div:drop { border: 2px dashed gray } |
:first-of-type | Selects the first element of its type among siblings | p:first-of-type { font-size: 24px } |
:fullscreen | Selects an element that is in full-screen mode | video:fullscreen { width: 100% } |
:in-range | Selects an input element with a value within a specified range | input[type="range"]:in-range { background-color: green } |
:indeterminate | Selects a checkbox that is in an indeterminate state | input[type="checkbox"]:indeterminate { opacity: 0.5 } |
:invalid | Selects an input element with an invalid value | input:invalid { border-color: red } |
:last-of-type | Selects the last element of its type among siblings | p:last-of-type { font-size: 24px } |
:link | Selects an unvisited link | a:link { color: blue } |
:nth-of-type | Selects elements based on their position among siblings, counting only elements of the same type | p:nth-of-type(odd) { background-color: lightgray } |
:only-of-type | Selects elements that are the only element of their type among siblings | h1:only-of-type { font-size: 36px } |
:optional | Selects an input element that is not required | input:optional { border-color: gray } |
:out-of-range | Selects an input element with a value outside a specified range | input[type="range"]:out-of-range { background-color: red } |
:required | Selects an input element that is required | input:required { border-color: green } |
:valid | Selects an input element with a valid value | input:valid { border-color: green } |
:visited | Selects a visited link | a:visited { color: purple } |