Skip to content
Amós Rivera edited this page Sep 15, 2015 · 1 revision

Pseudo-selectors

pseudo-selector use description state
:contains :contains('example string') Select all elements that contain the specified text. supported
:has :has(label) Selects elements which contain at least one element that matches the specified selector. supported
:eq li:eq(0) Select the element at index n within the matched set. supported
:gt :gt(0) Select all elements at an index greater than index within the matched set. supported
:lt :lt(5) Select all elements at an index less than index within the matched set. supported
:odd :odd Selects odd elements (based on it's position), zero-indexed. supported
:even :even Selects even elements (based on it's position), zero-indexed. supported
:selected :selected Selects all elements that are selected. supported
:checked :checked Matches all checkbox, radio and select elements that are checked or selected. supported
:visible :visible Selects all elements that are visible. no support
:target :target Selects the target element indicated by the fragment identifier of the document's URI (the hash at the end of the url). no support
:root :root Selects the element that is the root of the document. Most of the time it will be no support
:parent :parent Select all elements that have at least one child node (either an element or text). supported
:only-of-type :only-of-type Selects all elements that have no siblings with the same element name. partial support
:only-child :only-child Selects all elements that are the only child of their parent. partial support
nth-of-type nth-of-type Selects all elements that are the nth child of their parent in relation to siblings with the same element name. partial support
:nth-last-of-type :nth-last-of-type Selects all the elements that are the nth-child of their parent in relation to siblings with the same element name, counting from the last element to the first. partial support
nth-last-child nth-last-child Selects all elements that are the nth-child of their parent, counting from the last element to the first. partial support
nth-child nth-child Selects all elements that are the nth-child of their parent. partial support
:not :not Selects all elements that do not match the given selector. supported
:last-of-type :last-of-type Selects all elements that are the last among siblings of the same element name. partial support
:hidden :hidden Selects all elements that are the last among siblings of the same element name. no support
:first :first Selects the first matched element. partial support
:focus :focus Selects element if it is currently focused. no support
:enabled :enabled Selects all elements that are enabled. supported
:empty :empty Select all elements that have no children (including text nodes). supported
:disabled :disabled Selects all elements that are disabled. supported
:animated :animated Select all elements that are in the progress of an animation at the time the selector is run. no support
:input :input Selects all input, textarea, select and button elements. supported
:button :button Selects all elements of type button. supported
:checkbox :checkbox Selects all elements of type checkbox. supported
:file :file Selects all elements of type file. supported
:image :image Selects all elements of type image. supported
:password :password Selects all elements of type password. supported
:radio :radio Selects all elements of type radio. supported
:reset :reset Selects all elements of type reset. supported
:submit :submit Selects all elements of type submit. supported
:text :text Selects all elements of type text. supported
Clone this wiki locally