Working Draft · selectors

Selectors

75 selectors defined by this specification, 65 of them known to at least one browser (the others are badged Not in any browser yet).

Each feature in detail

:active

Selector Baseline: widely availablesince January 2018

Spec The :active pseudo-class applies while an element is being “activated” by the user, as defined by the host language; for example, while a hyperlink is being triggered.

MDN The :active CSS pseudo-class represents an element (such as a button) that is being activated by the user. When using a mouse, "activation" typically starts when the user presses down the primary mouse button.

Live preview Example from MDN
.joinBtn {
  width: 10em;
  height: 5ex;
  background-image: linear-gradient(135deg, #f34079 40%, #fc894d);
  border: none;
  border-radius: 5px;
  font-weight: bold;
  color: white;
  cursor: pointer;
}

.joinBtn:active {
  box-shadow: 2px 2px 5px #fc894d;
}

Syntax

:active

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :active
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:autofill

Selector Limited availability Modern CSS: :autofill

Spec The :autofill pseudo-class represents input elements that have been automatically filled by the user agent, and have not been subsequently altered by the user.

MDN The :autofill CSS pseudo-class matches when an <input> element has its value autofilled by the browser. The class stops matching if the user edits the field.

Live preview Example from MDN
input {
  border: 3px solid black;
}
input:autofill {
  outline: 5px solid magenta;
  border: 3px dashed yellow;
}

Syntax

:autofill

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :autofill
Chrome 110
Edge 110
Firefox 86
Safari 15
Chrome Android 110
Safari iOS 15

First version with support, from MDN browser-compat-data.

:blank

Selector Not in any browser yet

Spec The :blank pseudo-class applies to user-input elements whose input value is empty (consists of the empty string or otherwise null input).

MDN The :blank CSS pseudo-class selects empty user input elements (e.g., <input> or <textarea>).

Live preview Example from MDN
textarea:blank {
  border: 3px solid red;
}

Syntax

:blank

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

:buffering

Selector Limited availability Modern CSS: Media element pseudo-classes

Spec The :buffering pseudo-class represents an element that is capable of being “played” or “paused”, when that element cannot continue playing because it is actively attempting to obtain media data but has not yet obtained enough data to resume playback. (Note that the element is still considered to be “playing” when it is “buffering”. Whenever :buffering matches an element, :playing also matches the element.)

MDN The :buffering CSS pseudo-class selector represents an element that is playable, such as <audio> or <video>, when the playable element is buffering a media resource.

Syntax

:buffering

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :buffering
Chrome 158
Edge 158
Firefox 150
Safari 15.4
Chrome Android 158
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:checked

Selector Baseline: widely availablesince January 2018

Spec When such elements are toggled “on” the :checked pseudo-class applies. For example, [HTML] defines that checked checkboxes, radio buttons, and selected <option> elements match :checked. Similarly, when such elements are toggled “off”, the :unchecked pseudo-class applies.

MDN The :checked CSS pseudo-class selector represents any radio (<input type="radio">), checkbox (<input type="checkbox">), or option (<option> in a <select> element) that is checked or toggled to an on state.

Live preview Example from MDN
label {
  display: block;
  margin-top: 0.5em;
}

fieldset {
  margin-top: 0.5em;
}

input:checked {
  border: none;
  outline: 2px solid deeppink;
}

Syntax

:checked

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :checked
Chrome 1
Edge 12
Firefox 1
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:current

Selector

Spec The :current pseudo-class represents the element, or an ancestor of the element, that is currently being displayed.

MDN The :current CSS pseudo-class selector represents an element or the ancestor of an element that is currently being displayed or highlighted.

Live preview Example from MDN
html {
  font-family: "Helvetica", "Arial";
}

p {
  font-size: 1.5rem;
  line-height: 1.5;
  width: 90%;
  margin: 0 auto;
}

@layer no-support {
  body::before {
    background-color: wheat;
    display: block;
    text-align: center;
    padding: 1em 0;
  }
  @supports not selector(::search-text) {
    body::before {
      content: "Your browser doesn't support the ::search-text pseudo-element.";
    }
  }
  @supports not selector(:current) {
    body::before {
      content: "Your browser doesn't support the :current pseudo-class.";
    }
  }
}

::search-text {
  background-color: purple;
  color: white;
  text-shadow: 1px 1px 1px black;
}

::search-text:current {
  background-color: crimson;
  text-decoration-line: underline;
  text-decoration-color: yellow;
  text-decoration-thickness: 3px;
}

Syntax

:current

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

:default

Selector Baseline: widely availablesince July 2022

Spec The :default pseudo-class applies to the one or more UI elements that are the default among a set of similar elements. Typically applies to context menu items, buttons and select lists/menus.

MDN The :default CSS pseudo-class selects form elements that are the default in a group of related elements.

Live preview Example from MDN
label {
  display: block;
  margin-top: 0.5em;
}

fieldset {
  margin-top: 0.5em;
}

input:default {
  border: none;
  outline: 2px solid deeppink;
}

Syntax

:default

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :default
Chrome 10
Edge 79
Firefox 4
Safari 5
Chrome Android 18
Safari iOS 5

First version with support, from MDN browser-compat-data.

:defined

Selector Baseline: widely availablesince July 2022

Spec In some host languages, elements can have a distinction between being “defined”/“constructed” or not. The :defined pseudo-class matches elements that are fully defined, as dictated by the host language.

MDN The :defined CSS pseudo-class represents any element that has been defined. This includes any standard element built into the browser and custom elements that have been successfully defined (i.e., with the CustomElementRegistry.define() method).

Live preview Example from MDN
custom-element {
  display: block;
  border: 5px dashed grey;
  border-radius: 1rem;
  height: 100px;
  width: 400px;
  padding: 1rem;
  position: relative;
  user-select: none;
}

code {
  background: #cccccc;
}

#btn {
  margin-top: 1rem;
  cursor: pointer;
}

custom-element:not(:defined) {
  border-color: grey;
  color: grey;
}

custom-element:defined {
  background-color: wheat;
  border-color: black;
  color: black;
}

/* show loading message */
custom-element:not(:defined)::before {
  content: "Loading...";
  position: absolute;
  inset: 0;
  align-content: center;
  text-align: center;
  font-size: 2rem;
  background-color: white;
  border-radius: 1rem;
}

/* remove the loading message */
custom-element:defined::before {
  content: "";
}

Syntax

:defined

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :defined
Chrome 54
Edge 79
Firefox 63
Safari 10
Chrome Android 54
Safari iOS 10

First version with support, from MDN browser-compat-data.

:dir()

Selector Baseline: widely availablesince June 2026 Modern CSS: :dir()

Spec The :dir() pseudo-class allows the author to write selectors that represent an element based on its directionality as determined by the document language. For example, [HTML] defines how to determine the directionality of an element, based on a combination of the dir attribute, the surrounding text, and other factors. As another example, the its:dir and dirRule element of the Internationalization Tag Set [ITS20] are able to define the directionality of an element in [XML10].

MDN The :dir() CSS pseudo-class matches elements based on the directionality of the text contained in them.

Browser support

First browser version supporting :dir()
Chrome 120
Edge 120
Firefox 49
Safari 16.4
Chrome Android 120
Safari iOS 16.4

First version with support, from MDN browser-compat-data.

:disabled

Selector Baseline: widely availablesince January 2018

Spec Conversely, the :disabled pseudo-class represents user interface elements that are in a disabled state; such elements must have a corresponding enabled state.

MDN The :disabled CSS pseudo-class represents any disabled element. An element is disabled if it can't be activated (selected, clicked on, typed into, etc.) or accept focus. The element also has an enabled state, in which it can be activated or accept focus.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

*:disabled {
  background-color: dimgrey;
  color: linen;
  opacity: 1;
}

Syntax

:disabled

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :disabled
Chrome 1
Edge 12
Firefox 1
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:empty

Selector Baseline: widely availablesince January 2018

Spec The :empty pseudo-class represents an element that has no children except, optionally, document white space characters. In terms of the document tree, only element nodes and content nodes (such as [DOM] text nodes, and entity references) whose data has a non-zero length must be considered as affecting emptiness; comments, processing instructions, and other nodes must not affect whether an element is considered empty or not.

MDN The :empty CSS pseudo-class represents any element that has no children. Children can be either element nodes or text (including whitespace). Comments, processing instructions, and CSS content do not affect whether an element is considered empty.

Live preview Example from MDN
div:empty {
  outline: 2px solid deeppink;
  height: 1em;
}

Syntax

:empty

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :empty
Chrome 1
Edge 12
Firefox 1
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:enabled

Selector Baseline: widely availablesince January 2018

Spec The :enabled pseudo-class represents user interface elements that are in an enabled state; such elements must have a corresponding disabled state.

MDN The :enabled CSS pseudo-class represents any enabled element. An element is enabled if it can be activated (selected, clicked on, typed into, etc.) or accept focus. The element also has a disabled state, in which it can't be activated or accept focus.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

*:enabled {
  background-color: gold;
}

Syntax

:enabled

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :enabled
Chrome 1
Edge 12
Firefox 1
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:first-child

Selector Baseline: widely availablesince January 2018

Spec The :first-child pseudo-class represents an element that is first among its inclusive siblings. Same as :nth-child(1).

MDN The :first-child CSS pseudo-class represents the first element among a group of sibling elements.

Live preview Example from MDN
p {
  font-weight: bold;
}

li:first-child {
  border: 2px solid orange;
}

Syntax

:first-child

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :first-child
Chrome 4
Edge 12
Firefox 3
Safari 3.1
Chrome Android 18
Safari iOS 4

First version with support, from MDN browser-compat-data.

:first-of-type

Selector Baseline: widely availablesince January 2018

Spec The :first-of-type pseudo-class represents the same element as :nth-of-type(1).

MDN The :first-of-type CSS pseudo-class represents the first element of its type (tag name) among a group of sibling elements.

Live preview Example from MDN
dt {
  font-weight: bold;
}

dd {
  margin: 3px;
}

dd:first-of-type {
  border: 2px solid orange;
}

Syntax

:first-of-type

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :first-of-type
Chrome 1
Edge 12
Firefox 3.5
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:focus

Selector Baseline: widely availablesince January 2018

Spec The :focus pseudo-class applies while an element (or pseudo-element) has the focus (accepts keyboard or other forms of input).

MDN The :focus CSS pseudo-class represents an element (such as a form input) that has received focus. It is generally triggered when the user clicks or taps on an element or selects it with the keyboard's <kbd>Tab</kbd> key.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

input:focus {
  background-color: lightblue;
}

select:focus {
  background-color: ivory;
}

Syntax

:focus

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :focus
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:focus-visible

Selector Baseline: widely availablesince September 2024

Spec While the :focus pseudo-class always matches the currently-focused element, UAs only sometimes visibly indicate focus (such as by drawing a “focus ring”), instead using a variety of heuristics to visibly indicate the focus only when it would be most helpful to the user. The :focus-visible pseudo-class matches a focused element (or pseudo-element) in these situations only, allowing authors to change the appearance of the focus indicator without changing when a focus indicator appears.

MDN The :focus-visible pseudo-class applies while an element matches the :focus pseudo-class and the UA (User Agent) determines via heuristics that the focus should be made evident on the element. (Many browsers show a "focus ring" by default in this case.)

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

input:focus-visible {
  outline: 2px solid crimson;
  border-radius: 3px;
}

select:focus-visible {
  border: 2px dashed crimson;
  border-radius: 3px;
  outline: none;
}

Syntax

:focus-visible

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :focus-visible
Chrome 86
Edge 86
Firefox 85
Safari 15.4
Chrome Android 86
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:focus-within

Selector Baseline: widely availablesince July 2022

Spec The :focus-within pseudo-class applies to any element (or pseudo-element) for which the :focus pseudo-class applies, as well as to an element (or pseudo-element) whose descendant in the flat tree (including non-element nodes, such as text nodes) matches the conditions for matching :focus.

MDN The :focus-within CSS pseudo-class matches an element if the element or any of its descendants are focused. In other words, it represents an element that is itself matched by the :focus pseudo-class or has a descendant that is matched by :focus. (This includes descendants in shadow trees.)

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

label:focus-within {
  font-weight: bold;
}

Syntax

:focus-within

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :focus-within
Chrome 60
Edge 79
Firefox 52
Safari 10.1
Chrome Android 60
Safari iOS 10.3

First version with support, from MDN browser-compat-data.

:fullscreen

Selector Limited availability Modern CSS: Fullscreen API

Spec The :fullscreen pseudo-class represents an element which is displayed in a mode that takes up most (usually all) of the screen, such as that defined by the Fullscreen API. [FULLSCREEN]

MDN The :fullscreen CSS pseudo-class matches every element that is currently in fullscreen mode. If multiple elements have been put into fullscreen mode, this selects them all.

Live preview Example from MDN
.element {
  background-color: lightyellow;
}

.element:fullscreen {
  background-color: lightpink;
}

.element {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: sans-serif;
  padding: 1.2em;
}

Syntax

:fullscreen

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :fullscreen
Chrome 71
Edge 12
Firefox 64
Safari 16.4
Chrome Android 71
Safari iOS 16.4

First version with support, from MDN browser-compat-data.

:future

Selector Limited availability

Spec The :future pseudo-class represents any element that is defined to occur entirely after a :current element. For example, the WebVTT spec defines the :future pseudo-class relative to the current playback position of a media element. If a time-based order of elements is not defined by the document language, then this represents any element that is a (possibly indirect) next sibling of a :current element.

MDN The :future CSS pseudo-class selector is a time-dimensional pseudo-class that will match for any element which appears entirely after an element that matches :current. For example in a video with captions which are being displayed by WebVTT.

Syntax

:future

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :future
Chrome 23
Edge 79
Firefox No
Safari 7
Chrome Android 25
Safari iOS 7

First version with support, from MDN browser-compat-data.

:has()

Selector Baseline: widely availablesince June 2026 Modern CSS: :has()

Spec The relational pseudo-class, :has(), is a functional pseudo-class taking a <relative-selector-list> as an argument. It represents an element if any of the relative selectors would match at least one element when anchored against this element.

MDN The functional :has() CSS pseudo-class represents an element if any of the relative selectors that are passed as an argument match at least one element when anchored against this element. This pseudo-class presents a way of selecting a parent element or a previous sibling element with respect to a reference element by taking a relative selector list as an argument.

Live preview Example from MDN
section:has(.featured) {
  border: 2px solid blue;
}

Browser support

First browser version supporting :has()
Chrome 105
Edge 105
Firefox 121
Safari 15.4
Chrome Android 105
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:heading

Selector Limited availability Experimental Modern CSS: Heading pseudo-classes

Spec The (non-functional) :heading pseudo-class matches an element which has a heading level, with respect to the semantics defined by the document language (e.g. [HTML5]).

MDN The :heading CSS pseudo-class matches all heading elements in a document.

Live preview Example from MDN
:heading {
  color: tomato;
  font-style: italic;
}

Syntax

:heading

:heading( <level># )

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :heading
Chrome No
Edge No
Firefox Preview (flag)
Safari 27
Chrome Android No
Safari iOS 27

First version with support, from MDN browser-compat-data.

:hover

Selector Baseline: widely availablesince January 2018

Spec The :hover pseudo-class applies while the user designates an element (or pseudo-element) with a pointing device, but does not necessarily activate it. For example, a visual user agent could apply this pseudo-class when the cursor (mouse pointer) hovers over a box generated by the element. Interactive user agents that cannot detect hovering due to hardware limitations (e.g., a pen device that does not detect hovering) are still conforming; the selector will simply never match in such a UA.

MDN The :hover CSS pseudo-class matches an element when a user interacts with it using a pointing device. The pseudo-class is generally triggered when the user moves the cursor (mouse pointer) over an element without pressing the mouse button.

Live preview Example from MDN
.joinBtn {
  width: 10em;
  height: 5ex;
  background-color: gold;
  border: 2px solid firebrick;
  border-radius: 10px;
  font-weight: bold;
  color: black;
  cursor: pointer;
}

.joinBtn:hover {
  background-color: bisque;
}

Syntax

:hover

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :hover
Chrome 1
Edge 12
Firefox 1
Safari 2
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:in-range

Selector Baseline: widely availablesince January 2018

Spec The :in-range and :out-of-range pseudo-classes apply only to elements that have range limitations. An element is :in-range or :out-of-range when the value that the element is bound to is in range or out of range with respect to its range limits as defined by the document language. An element that lacks data range limits or is not a form control is neither :in-range nor :out-of-range. E.g. a slider element with a value of 11 presented as a slider control that only represents the values from 1-10 is :out-of-range. Another example is a menu element with a value of "E" that happens to be presented in a popup menu that only has choices "A", "B" and "C".

MDN The :in-range CSS pseudo-class represents an <input> element whose current value is within the range limits specified by the min and max attributes.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

input:in-range {
  background-color: palegreen;
}

Syntax

:in-range

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :in-range
Chrome 10
Edge 13
Firefox 29
Safari 5.1
Chrome Android 18
Safari iOS 5

First version with support, from MDN browser-compat-data.

:indeterminate

Selector Baseline: widely availablesince July 2022

Spec If an element that could match :checked or :unchecked is neither "on" nor "off", the :indeterminate pseudo-class applies. :indeterminate also matches elements which do not have a notion of being "checked", but whose "value" is still in an indeterminate state, such as a progress meter whose progress percentage is unknown.

MDN The :indeterminate CSS pseudo-class represents any form element whose state is indeterminate, such as checkboxes that have been set to an indeterminate state with JavaScript, radio buttons which are members of a group in which all radio buttons are unchecked, and <progress> elements with no value attribute.

Live preview Example from MDN
input:indeterminate + label {
  background: lime;
}

fieldset {
  padding: 1em 0.75em;
}

fieldset:first-of-type {
  margin-bottom: 1.5rem;
}

fieldset:not(:first-of-type) > div:not(:last-child) {
  margin-bottom: 0.5rem;
}

Syntax

:indeterminate

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :indeterminate
Chrome 1
Edge 12
Firefox 2
Safari 3
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:interest-source

Selector Limited availability Experimental Modern CSS: Interest invokers

Spec The :interest-source pseudo-class applies to an interest source element that the user is currently showing interest in, and the :interest-target pseudo-class applies to the associated interest target of an element matching :interest-source.

MDN The :interest-source CSS pseudo-class represents an interest invoker element when interest is shown on it.

Live preview Example from MDN
button {
  margin: 10px;
  padding: 5px 10px;
  border: 1px solid #dddddd;
  border-radius: 5px;
  font-size: 1.5em;
  background-color: #eeeeee;

  cursor: pointer;
}

button:interest-source {
  background-color: hotpink;
  color: purple;
}

Syntax

:interest-source

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :interest-source
Chrome 142
Edge 142
Firefox No
Safari No
Chrome Android 142
Safari iOS No

First version with support, from MDN browser-compat-data.

:interest-target

Selector Limited availability Experimental Modern CSS: Interest invokers

Spec The :interest-source pseudo-class applies to an interest source element that the user is currently showing interest in, and the :interest-target pseudo-class applies to the associated interest target of an element matching :interest-source.

MDN The :interest-target CSS pseudo-class represents the target element associated with an interest invoker when interest is shown on that invoker.

Live preview Example from MDN
body {
  margin: 10px;
}

button {
  padding: 5px 10px;
  border: 1px solid #dddddd;
  border-radius: 5px;
  background-color: #eeeeee;

  cursor: pointer;
}

p:interest-target {
  font-size: 1.5em;
  font-family: sans-serif;
  padding: 10px;
  background-color: hotpink;
  color: purple;
}

Syntax

:interest-target

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :interest-target
Chrome 142
Edge 142
Firefox No
Safari No
Chrome Android 142
Safari iOS No

First version with support, from MDN browser-compat-data.

:invalid

Selector Baseline: widely availablesince January 2018

Spec An element is :valid or :invalid when its contents or value is, respectively, valid or invalid with respect to data validity semantics defined by the document language (e.g. [XFORMS11] or [HTML]). An element which lacks data validity semantics is neither :valid nor :invalid.

MDN The :invalid CSS pseudo-class represents any <form>, <fieldset>, <input> or other <form> element whose contents fail to validate.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

input:invalid {
  background-color: ivory;
  border: none;
  outline: 2px solid red;
  border-radius: 5px;
}

Syntax

:invalid

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :invalid
Chrome 10
Edge 12
Firefox 4
Safari 5
Chrome Android 18
Safari iOS 5

First version with support, from MDN browser-compat-data.

:is()

Selector Baseline: widely availablesince July 2023

Spec The matches-any pseudo-class, :is(), is a functional pseudo-class taking a <forgiving-selector-list> as its sole argument.

MDN The :is() CSS pseudo-class function takes a selector list as its argument, and selects any element that can be selected by one of the selectors in that list. This is useful for writing large selectors in a more compact form.

Live preview Example from MDN
ol {
  list-style-type: upper-alpha;
  color: darkblue;
}

:is(ol, ul, menu:unsupported) :is(ol, ul) {
  color: green;
}

:is(ol, ul) :is(ol, ul) ol {
  list-style-type: lower-greek;
  color: chocolate;
}

Browser support

First browser version supporting :is()
Chrome 88
Edge 88
Firefox 78
Safari 14
Chrome Android 88
Safari iOS 14

First version with support, from MDN browser-compat-data.

:lang()

Selector Baseline: widely availablesince January 2018

Spec If the document language specifies how the (human) content language of an element is determined, it is possible to write selectors that represent an element based on its content language. The :lang() pseudo-class, which accepts a comma-separated list of one or more language ranges, represents an element whose content language is one of the languages listed in its argument. Each language range in :lang() is an extended language range, as defined in BCP 47, and must be a valid CSS <ident> or <string>. (Thus language ranges containing asterisks, for example, must be either correctly escaped or quoted as strings, e.g. :lang(\*-Latn) or :lang("*-Latn").)

MDN The :lang() CSS pseudo-class matches elements based on the language they are determined to be in.

Live preview Example from MDN
*:lang(en-US) {
  outline: 2px solid deeppink;
}

Browser support

First browser version supporting :lang()
Chrome 1
Edge 12
Firefox 1
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:last-child

Selector Baseline: widely availablesince January 2018

Spec The :last-child pseudo-class represents an element that is last among its inclusive siblings. Same as :nth-last-child(1).

MDN The :last-child CSS pseudo-class represents the last element among a group of sibling elements.

Live preview Example from MDN
p {
  font-weight: bold;
}

li:last-child {
  border: 2px solid orange;
}

Syntax

:last-child

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :last-child
Chrome 1
Edge 12
Firefox 1
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:last-of-type

Selector Baseline: widely availablesince January 2018

Spec The :last-of-type pseudo-class represents the same element as :nth-last-of-type(1).

MDN The :last-of-type CSS pseudo-class represents the last element of its type (tag name) among a group of sibling elements.

Live preview Example from MDN
dt {
  font-weight: bold;
}

dd {
  margin: 3px;
}

dd:last-of-type {
  border: 2px solid orange;
}

Syntax

:last-of-type

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :last-of-type
Chrome 1
Edge 12
Firefox 3.5
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:matches()

Selector Not in any browser yet

Spec As previous drafts of this specification used the name :matches() for this pseudo-class, UAs may additionally implement this obsolete name as a legacy selector alias for :is() if needed for backwards-compatibility.

:modal

Selector Baseline: widely availablesince March 2025

Spec The :modal pseudo-class represents an element which is in a state that excludes all interaction with elements outside it until it has been dismissed. Multiple elements can be :modal simultaneously, with only one of them active (able to receive input).

MDN The :modal CSS pseudo-class matches an element that is in a state in which it excludes all interaction with elements outside it until the interaction has been dismissed. Multiple elements can be selected by the :modal pseudo-class at the same time, but only one of them will be active and able to receive input.

Live preview Example from MDN
button {
  display: block;
  margin: auto;
  width: 10rem;
  height: 2rem;
}

:modal {
  background-color: beige;
  border: 2px solid burlywood;
  border-radius: 5px;
}

p {
  color: black;
}

Syntax

:modal

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :modal
Chrome 105
Edge 105
Firefox 103
Safari 15.6
Chrome Android 105
Safari iOS 15.6

First version with support, from MDN browser-compat-data.

:muted

Selector Limited availability Modern CSS: Media element pseudo-classes

Spec The :muted pseudo-class represents an element that is capable of making sound, but is currently “muted“ (forced silent). (For the audio and video elements of HTML, see muted. [HTML])

MDN The :muted CSS pseudo-class selector represents an element that is capable of making sound, such as <audio> or <video>, but is muted (forced silent).

Syntax

:muted

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :muted
Chrome 158
Edge 158
Firefox 150
Safari 15.4
Chrome Android 158
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:not()

Selector Baseline: widely availablesince July 2023

Spec The negation pseudo-class, :not(), is a functional pseudo-class taking a <complex-real-selector-list> as an argument. It represents an element that is not represented by its argument.

MDN The :not() CSS pseudo-class represents elements that do not match a list of selectors. Since it prevents specific items from being selected, it is known as the negation pseudo-class.

Live preview Example from MDN
p:not(.irrelevant) {
  font-weight: bold;
}

p > strong,
p > b.important {
  color: crimson;
}

p > :not(strong, b.important) {
  color: darkmagenta;
}

Browser support

First browser version supporting :not()
Chrome 1
Edge 12
Firefox 1
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:nth-child()

Selector Baseline: widely availablesince January 2018 Modern CSS: :nth-child() of <selector>

MDN The :nth-child() CSS pseudo-class matches elements based on the indexes of the elements in the child list of their parents. In other words, the :nth-child() selector selects child elements according to their position among all the sibling elements within a parent element.

Live preview Example from MDN
p {
  font-weight: bold;
}

li:nth-child(-n + 3) {
  border: 2px solid orange;
  margin-bottom: 1px;
}

li:nth-child(even) {
  background-color: lightyellow;
}

Syntax

:nth-child(An+B [of S]? )

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :nth-child()
Chrome 1
Edge 12
Firefox 3.5
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:nth-col()

Selector Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

:nth-col(An+B)

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

:nth-last-child()

Selector Baseline: widely availablesince January 2018 Modern CSS: :nth-child() of <selector>

MDN The :nth-last-child() CSS pseudo-class matches elements based on their position among a group of siblings, counting from the end.

Live preview Example from MDN
p {
  font-weight: bold;
}

li:nth-last-child(-n + 3) {
  border: 2px solid orange;
  margin-top: 1px;
}

li:nth-last-child(even) {
  background-color: lightyellow;
}

Syntax

:nth-last-child(An+B [of S]? )

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :nth-last-child()
Chrome 4
Edge 12
Firefox 3.5
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:nth-last-col()

Selector Not in any browser yet

No prose in the spec's definition and no MDN page yet: the spec link below is the only description.

Syntax

:nth-last-col(An+B)

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

:nth-last-of-type()

Selector Baseline: widely availablesince January 2018

MDN The :nth-last-of-type() CSS pseudo-class matches elements based on their position among siblings of the same type (tag name), counting from the end.

Live preview Example from MDN
dt {
  font-weight: bold;
}

dd {
  margin: 3px;
}

dd:nth-last-of-type(3n) {
  border: 2px solid orange;
}

Syntax

:nth-last-of-type(An+B)

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :nth-last-of-type()
Chrome 4
Edge 12
Firefox 3.5
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:nth-of-type()

Selector Baseline: widely availablesince January 2018

MDN The :nth-of-type() CSS pseudo-class matches elements based on their position among siblings of the same type (tag name).

Live preview Example from MDN
dt {
  font-weight: bold;
}

dd {
  margin: 3px;
}

dd:nth-of-type(even) {
  border: 2px solid orange;
}

Syntax

:nth-of-type(An+B)

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :nth-of-type()
Chrome 1
Edge 12
Firefox 3.5
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:only-child

Selector Baseline: widely availablesince January 2018

Spec The :only-child pseudo-class represents an element that has no siblings. Same as :first-child:last-child or :nth-child(1):nth-last-child(1), but with a lower specificity.

MDN The :only-child CSS pseudo-class represents an element without any siblings. This is the same as :first-child:last-child or :nth-child(1):nth-last-child(1), but with a lower specificity.

Live preview Example from MDN
li:only-child {
  color: fuchsia;
}

b:only-child {
  text-decoration: underline;
}

Syntax

:only-child

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :only-child
Chrome 2
Edge 12
Firefox 1.5
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:only-of-type

Selector Baseline: widely availablesince January 2018

Spec The :only-of-type pseudo-class represents the same element as :first-of-type:last-of-type.

MDN The :only-of-type CSS pseudo-class represents an element that has no siblings of the same type (tag name).

Live preview Example from MDN
a:only-of-type {
  color: fuchsia;
}

dd:only-of-type {
  background-color: bisque;
}

Syntax

:only-of-type

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :only-of-type
Chrome 1
Edge 12
Firefox 3.5
Safari 3.1
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:open

Selector Baseline: newly availablesince May 2026 Modern CSS: :open

Spec The :open pseudo-class represents an element that has both “open” and “closed” states, and which is currently in the “open” state.

MDN The :open CSS pseudo-class represents an element that has open and closed states, only when it is currently in the open state.

Live preview Example from MDN
details:open > summary {
  background-color: pink;
}

:is(select, input):open {
  background-color: pink;
}

@supports not selector(:open) {
  body::before {
    content: "Your browser doesn't support the :open selector.";
    background-color: wheat;
    display: block;
    text-align: center;
    padding: 1rem 0;
  }
}

Syntax

:open

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :open
Chrome 133
Edge 133
Firefox 136
Safari 26.5
Chrome Android 133
Safari iOS 26.5

First version with support, from MDN browser-compat-data.

:optional

Selector Baseline: widely availablesince January 2018

Spec A form element is :required or :optional if a value for it is, respectively, required or optional before the form it belongs to can be validly submitted. Elements that are not form elements are neither required nor optional.

MDN The :optional CSS pseudo-class represents any <input>, <select>, or <textarea> element that does not have the required attribute set on it.

Live preview Example from MDN
label {
  display: block;
  margin-top: 0.5em;
}

fieldset {
  margin-top: 0.5em;
}

*:optional {
  background-color: palegreen;
}

Syntax

:optional

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :optional
Chrome 10
Edge 12
Firefox 4
Safari 5
Chrome Android 18
Safari iOS 5

First version with support, from MDN browser-compat-data.

:out-of-range

Selector Baseline: widely availablesince January 2018

Spec The :in-range and :out-of-range pseudo-classes apply only to elements that have range limitations. An element is :in-range or :out-of-range when the value that the element is bound to is in range or out of range with respect to its range limits as defined by the document language. An element that lacks data range limits or is not a form control is neither :in-range nor :out-of-range. E.g. a slider element with a value of 11 presented as a slider control that only represents the values from 1-10 is :out-of-range. Another example is a menu element with a value of "E" that happens to be presented in a popup menu that only has choices "A", "B" and "C".

MDN The :out-of-range CSS pseudo-class represents an <input> element whose current value is outside the range limits specified by the min and max attributes.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

input:out-of-range {
  background-color: orangered;
}

Syntax

:out-of-range

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :out-of-range
Chrome 10
Edge 13
Firefox 29
Safari 5.1
Chrome Android 18
Safari iOS 5

First version with support, from MDN browser-compat-data.

:past

Selector Limited availability

Spec The :past pseudo-class represents any element that is defined to occur entirely prior to a :current element. For example, the WebVTT spec defines the :past pseudo-class relative to the current playback position of a media element. If a time-based order of elements is not defined by the document language, then this represents any element that is a (possibly indirect) previous sibling of a :current element.

MDN The :past CSS pseudo-class selector is a time-dimensional pseudo-class that will match for any element which appears entirely before an element that matches :current. For example in a video with captions which are being displayed by WebVTT.

Syntax

:past

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :past
Chrome 23
Edge 79
Firefox No
Safari 7
Chrome Android 25
Safari iOS 7

First version with support, from MDN browser-compat-data.

:paused

Selector Limited availability Modern CSS: Media element pseudo-classes

Spec The :paused pseudo-class represents an element that is capable of being “played” or “paused”, when that element is “paused” (i.e. not ”playing”). (This includes both an explicit “paused” state, and other non-playing states like “loaded, hasn’t been activated yet”, etc.)

MDN The :paused CSS pseudo-class selector represents an element that is playable, such as <audio> or <video>, when that element is "paused" (i.e., not "playing").

Syntax

:paused

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :paused
Chrome 158
Edge 158
Firefox 150
Safari 15.4
Chrome Android 158
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:picture-in-picture

Selector Limited availability Modern CSS: Picture-in-picture (video)

Spec The :picture-in-picture pseudo-class represents an element whose contents are being displayed in a “picture-in-picture” mode (i.e. displayed in a window confined to part of the screen and overlaying other content) rather than embedded in the document. For example, this pseudo-class can be used to style a video element’s box while its contents are being played in an overlaid window using the Picture-in-Picture API. [picture-in-picture]

MDN The :picture-in-picture CSS pseudo-class matches the element which is currently in picture-in-picture mode.

Syntax

:picture-in-picture

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :picture-in-picture
Chrome 110
Edge 110
Firefox 153
Safari 13.1
Chrome Android 110
Safari iOS 13.4

First version with support, from MDN browser-compat-data.

:placeholder-shown

Selector Baseline: widely availablesince July 2022

Spec Input elements can sometimes show placeholder text as a hint to the user on what to type in. See, for example, the placeholder attribute in [HTML]. The :placeholder-shown pseudo-class matches an input element that is showing such placeholder text, whether that text is given by an attribute or a real element, or is otherwise implied by the UA.

MDN The :placeholder-shown CSS pseudo-class represents any <input> or <textarea> element that is currently displaying placeholder text.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

input:placeholder-shown {
  background-color: ivory;
  border: 2px solid darkorange;
  border-radius: 5px;
}

Syntax

:placeholder-shown

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :placeholder-shown
Chrome 47
Edge 79
Firefox 51
Safari 9
Chrome Android 47
Safari iOS 9

First version with support, from MDN browser-compat-data.

:playing

Selector Limited availability Modern CSS: Media element pseudo-classes

Spec The :playing pseudo-class represents an element that is capable of being “played” or “paused”, when that element is “playing”. (This includes both when the element is explicitly playing, and when it’s temporarily stopped for some reason not connected to user intent, but will automatically resume when that reason is resolved, such as a “buffering” or “stalled” state.)

MDN The :playing CSS pseudo-class selector represents the playback state of an element that is playable, such as <audio> or <video>, when that element is "playing". An element is considered to be playing if it is currently playing the media resource, or if it has temporarily stopped for reasons other than user intent (such as :buffering or :stalled).

Syntax

:playing

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :playing
Chrome 158
Edge 158
Firefox 150
Safari 15.4
Chrome Android 158
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:popover-open

Selector Baseline: newly availablesince January 2025 Modern CSS: Popover

Spec The :popover-open pseudo-class represents an element that has both “popover-showing” and “popover-hidden” states and which is currently in the “popover-showing” state.

MDN The :popover-open CSS pseudo-class represents a Popover API element (i.e., one with a popover attribute) that is in the showing state. You can use this to apply style to popover elements only when they are shown.

Syntax

:popover-open

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :popover-open
Chrome 114
Edge 114
Firefox 125
Safari 17
Chrome Android 114
Safari iOS 17

First version with support, from MDN browser-compat-data.

:read-only

Selector Baseline: widely availablesince January 2023

Spec An element matches :read-write if it is user-alterable, as defined by the document language. Otherwise, it is :read-only.

MDN The :read-only CSS pseudo-class selects elements (such as certain <input> types and <textarea>) that are not editable by the user. Elements on which the HTML attribute readonly doesn't have an effect (such as <input type="radio">, <input type="checkbox">, and all other non-form elements) are also selected by the :read-only pseudo-class. In fact, :read-only matches anything that :read-write doesn't match, making it equivalent to :not(:read-write).

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

*:read-only {
  font-weight: bold;
  color: indigo;
}

Syntax

:read-only

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :read-only
Chrome 1
Edge 13
Firefox 78
Safari 4
Chrome Android 18
Safari iOS 3.2

First version with support, from MDN browser-compat-data.

:read-write

Selector Baseline: widely availablesince January 2023

Spec An element matches :read-write if it is user-alterable, as defined by the document language. Otherwise, it is :read-only.

MDN The :read-write CSS pseudo-class represents an element (such as input or textarea) that is editable by the user.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

*:read-write {
  background-color: ivory;
  border: 2px solid darkorange;
  border-radius: 5px;
}

Syntax

:read-write

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :read-write
Chrome 1
Edge 13
Firefox 78
Safari 4
Chrome Android 18
Safari iOS 3.2

First version with support, from MDN browser-compat-data.

:required

Selector Baseline: widely availablesince January 2018

Spec A form element is :required or :optional if a value for it is, respectively, required or optional before the form it belongs to can be validly submitted. Elements that are not form elements are neither required nor optional.

MDN The :required CSS pseudo-class represents any <input>, <select>, or <textarea> element that has the required attribute set on it.

Live preview Example from MDN
label {
  display: block;
  margin-top: 0.5em;
}

fieldset {
  margin-top: 0.5em;
}

*:required {
  background-color: gold;
}

Syntax

:required

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :required
Chrome 10
Edge 12
Firefox 4
Safari 5
Chrome Android 18
Safari iOS 5

First version with support, from MDN browser-compat-data.

:root

Selector Baseline: widely availablesince January 2018

Spec The :root pseudo-class represents an element that is the root of the document.

MDN The :root CSS pseudo-class matches the root element of a tree representing the document. In HTML, :root represents the <html> element and is identical to the selector html, except that its specificity (0-1-0) is higher than html's (0-0-1).

Syntax

:root

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :root
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:scope

Selector Baseline: widely availablesince July 2022

Spec In some contexts, selectors are matched with respect to one or more scoping roots, such as when calling the querySelector() method in [DOM]. The :scope pseudo-class represents this scoping root, and may be either a true element or a virtual one (such as a DocumentFragment).

MDN The :scope CSS pseudo-class represents elements that are a reference point, or scope, for selectors to match against.

Live preview Example from MDN
div {
  padding: 10px;
}

@scope (.light-scheme) {
  :scope {
    background-color: plum;
  }

  a {
    color: indigo;
  }
}

@scope (.dark-scheme) {
  :scope {
    background-color: indigo;
    color: antiquewhite;
  }

  a {
    color: plum;
  }
}

Syntax

:scope

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :scope
Chrome 27
Edge 79
Firefox 32
Safari 7
Chrome Android 27
Safari iOS 7

First version with support, from MDN browser-compat-data.

:seeking

Selector Limited availability Modern CSS: Media element pseudo-classes

Spec The :seeking pseudo-class represents an element that is capable of ”seeking” when that element is ”seeking”. (For the audio and video elements of HTML, see HTML § 4.8.11.9 Seeking.)

MDN The :seeking CSS pseudo-class selector represents an element that is playable, such as <audio> or <video>, when the playable element is seeking a playback position in the media resource. A resource is considered to be seeking if the user has requested playback of a specific position in the media resource, but the media element has not yet reached that position.

Syntax

:seeking

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :seeking
Chrome 158
Edge 158
Firefox 150
Safari 15.4
Chrome Android 158
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:stalled

Selector Limited availability Modern CSS: Media element pseudo-classes

Spec The :stalled pseudo-class represents an element when that element cannot continue playing because it is actively attempting to obtain media data but it has failed to receive any data for some amount of time. For the audio and video elements of HTML, this amount of time is the media element stall timeout. [HTML] (Note that, like with the :buffering pseudo-class, the element is still considered to be “playing” when it is “stalled”. Whenever :stalled matches an element, :playing also matches the element.)

MDN The :stalled CSS pseudo-class selector represents an element that is playable, such as <audio> or <video>, when playback is stalled. A resource is considered to be stalled if the user has requested playback of a specific position in the media resource, but it has failed to receive any data for some amount of time. This is different from :buffering in that the media element is unexpectedly not loading data when stalled (e.g., due to a network error) for around 3 seconds (the exact time is user agent dependent).

Syntax

:stalled

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :stalled
Chrome 158
Edge 158
Firefox 150
Safari 15.4
Chrome Android 158
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:state()

Selector Baseline: newly availablesince May 2024 Modern CSS: :state()

MDN The :state() CSS pseudo-class matches custom elements that have the specified custom state.

Syntax

:state( <ident> )

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :state()
Chrome 125
Edge 125
Firefox 126
Safari 17.4
Chrome Android 125
Safari iOS 17.4

First version with support, from MDN browser-compat-data.

:target

Selector Baseline: widely availablesince January 2018

Spec The :target pseudo-class matches the document’s target elements. If the document’s URL has no fragment identifier, then the document has no target elements.

MDN The :target CSS pseudo-class selects the target element of the document. When the document is loaded, the target element is derived using the document's URL fragment identifier.

Live preview Example from MDN
p:target {
  background-color: gold;
}

/* Add a pseudo-element inside the target element */
p:target::before {
  font: 70% sans-serif;
  content: "►";
  color: limegreen;
  margin-right: 0.25em;
}

/* Style italic elements within the target element */
p:target i {
  color: red;
}

Syntax

:target

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :target
Chrome 1
Edge 12
Firefox 1
Safari 1.3
Chrome Android 18
Safari iOS 2

First version with support, from MDN browser-compat-data.

:unchecked

Selector Not in any browser yet

Spec When such elements are toggled “on” the :checked pseudo-class applies. For example, [HTML] defines that checked checkboxes, radio buttons, and selected <option> elements match :checked. Similarly, when such elements are toggled “off”, the :unchecked pseudo-class applies.

Syntax

:unchecked

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

:user-invalid

Selector Baseline: widely availablesince May 2026 Modern CSS: :user-valid and :user-invalid

Spec The :user-invalid and the :user-valid pseudo-classes represent an element with incorrect or correct input, respectively, but only after the user has significantly interacted with it. Their purpose is to help the user identify mistakes in their input.

MDN The :user-invalid CSS pseudo-class represents any validated form element whose value isn't valid based on their validation constraints, after the user has interacted with it.

Live preview Example from MDN
input:user-invalid {
  border: 2px solid red;
}

input:user-invalid + span::before {
  content: "✖";
  color: red;
}

Syntax

:user-invalid

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :user-invalid
Chrome 119
Edge 119
Firefox 88
Safari 16.5
Chrome Android 119
Safari iOS 16.5

First version with support, from MDN browser-compat-data.

:user-valid

Selector Baseline: widely availablesince May 2026 Modern CSS: :user-valid and :user-invalid

Spec The :user-invalid and the :user-valid pseudo-classes represent an element with incorrect or correct input, respectively, but only after the user has significantly interacted with it. Their purpose is to help the user identify mistakes in their input.

MDN The :user-valid CSS pseudo-class represents any validated form element whose value validates correctly based on its validation constraints. However, unlike :valid it only matches once the user has interacted with it.

Live preview Example from MDN
input:user-valid {
  border: 2px solid green;
}

input:user-valid + span::before {
  content: "✓";
  color: green;
}

Syntax

:user-valid

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :user-valid
Chrome 119
Edge 119
Firefox 88
Safari 16.5
Chrome Android 119
Safari iOS 16.5

First version with support, from MDN browser-compat-data.

:valid

Selector Baseline: widely availablesince January 2018

Spec An element is :valid or :invalid when its contents or value is, respectively, valid or invalid with respect to data validity semantics defined by the document language (e.g. [XFORMS11] or [HTML]). An element which lacks data validity semantics is neither :valid nor :invalid.

MDN The :valid CSS pseudo-class represents any <input> or other <form> element whose contents validate successfully. This allows you to easily make valid fields adopt an appearance that helps the user confirm that their data is formatted properly.

Live preview Example from MDN
label {
  display: block;
  margin-top: 1em;
}

input:valid {
  background-color: ivory;
  border: none;
  outline: 2px solid deepskyblue;
  border-radius: 5px;
  accent-color: gold;
}

Syntax

:valid

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :valid
Chrome 10
Edge 12
Firefox 4
Safari 5
Chrome Android 18
Safari iOS 5

First version with support, from MDN browser-compat-data.

:visited

Selector Baseline: widely availablesince July 2022

Spec User agents commonly display unvisited hyperlinks differently from previously visited ones. Selectors provides the pseudo-classes :link and :visited to distinguish them:

MDN The :visited CSS pseudo-class applies once the link has been visited by the user. For privacy reasons, the styles that can be modified using this selector are very limited. The :visited pseudo-class applies only to <a> and <area> elements that have an href attribute.

Live preview Example from MDN
p {
  font-weight: bold;
}

a:visited {
  color: forestgreen;
  text-decoration-color: hotpink;
}

Syntax

:visited

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :visited
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

:volume-locked

Selector Limited availability Modern CSS: Media element pseudo-classes

Spec The :volume-locked pseudo-class represents an element that is capable of making sound, and currently has its volume "locked" by the UA or the user, so the page author cannot change it. (For the audio and video elements of HTML, see the algorithm for setting the element’s effective media volume. [HTML])

MDN The :volume-locked CSS pseudo-class selector represents an element that is capable of making sound, such as <audio> or <video>, but the audio volume of the media element is currently "locked" by the user.

Syntax

:volume-locked

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting :volume-locked
Chrome 158
Edge 158
Firefox 150
Safari 15.4
Chrome Android 158
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

:where()

Selector Baseline: widely availablesince July 2023

Spec The Specificity-adjustment pseudo-class, :where(), is a functional pseudo-class with the same syntax and functionality as :is(). Unlike :is(), neither the :where() pseudo-class, nor any of its arguments, contribute to the specificity of the selector—​its specificity is always zero.

MDN The :where() CSS pseudo-class function takes a selector list as its argument, and selects any element that can be selected by one of the selectors in that list.

Live preview Example from MDN
ol {
  list-style-type: upper-alpha;
  color: darkblue;
}

/* Not applied to ol, because of lower specificity */
:where(ol, ul, menu:unsupported) :where(ol, ul) {
  color: green;
}

:where(ol, ul) :where(ol, ul) ol {
  list-style-type: lower-greek;
  color: chocolate;
}

Browser support

First browser version supporting :where()
Chrome 88
Edge 88
Firefox 78
Safari 14
Chrome Android 88
Safari iOS 14

First version with support, from MDN browser-compat-data.

+

Selector Not in any browser yet

Spec The next-sibling combinator is made of the “plus sign” (U+002B, +) code point that separates two compound selectors. The elements represented by the two compound selectors share the same parent in the document tree and the element represented by the first compound selector immediately precedes the element represented by the second one. Non-element nodes (e.g. text between elements) are ignored when considering the adjacency of elements.

Syntax

'+'

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

>

Selector Not in any browser yet

Spec A child combinator describes a childhood relationship between two elements. A child combinator is made of the "greater-than sign" (U+003E, >) code point and separates two compound selectors.

Syntax

'>'

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

||

Selector Not in any browser yet

Spec The column combinator, which consists of two pipes (||) represents the relationship of a column element to a cell element belonging to the column it represents. Column membership is determined based on the semantics of the document language only: whether and how the elements are presented is not considered. If a cell element belongs to more than one column, it is represented by a selector indicating membership in any of those columns.

Syntax

'|' '|'

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

~

Selector Not in any browser yet

Spec The subsequent-sibling combinator is made of the "tilde" (U+007E, ~) code point that separates two compound selectors. The elements represented by the two compound selectors share the same parent in the document tree and the element represented by the first compound selector precedes (not necessarily immediately) the element represented by the second one.

Syntax

'~'

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.