Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CSS supported selectors

Diego Perini edited this page Sep 6, 2025 · 18 revisions

What follows is a list of CSS selectors currently supported in latest NWSAPI version.

The list has been built upon current W3C Selectors Level 4 though it is still a work in progress.

Text and/or character selectors (content) have no meanings for applications, they don’t work on element nodes but on text nodes, which do not provide an event interface needed for selections.

Universal selector

* (asterisk) any Element

Tag, Id and Class selectors

E an Element of type E
E#fooId an E element with ID equal to “fooId”
E.fooClass an E element with CLASS equal to “fooClass”

Logical and relational combination pseudo-classes selectors

table{ border: 1px solid black; width: 100% }
| E:is(s1, s2, …) | an E element matching selectors s1, s2 (Matches-Any + Forgiving) |
| E:not(s1, s2, …) | an E element not matching selectors s1, s2 (Matches-None) |
| E:has(s1, s2, …) | an E Element matching relational selectors s1, s2 (No Nesting) |
| E:where(s1, s2, …) | an E Element matching selectors s1, s2 (Matches-Any + Specificity) |
| E:matches(s1, s2, …) | an E Element matching selectors s1, s2 (Matches-Any) |

NOTE: the :is() and :where() pseudo-classes are still named :matches() in most implementations |

Combinators selectors (child and siblings)

E F an F element descendant child of an E element
E > F an F element direct child of an E element
E + F an F element immediately preceded by an E element
E ~ F an F element preceded by an E element

Attribute selectors

E[foo] an E element with a “foo” attribute
E[foo=“bar”] an E element whose “foo” attribute value is exactly equal to bar
E[foo=“bar” i] an E element whose “foo” attribute value is case insensitive match of bar
E[foo=“bar” s] an E element whose “foo” attribute value is case sensitive match of bar
E[foo^=“bar”] an E element whose “foo” attribute value begins exactly with the string bar
E[foo$=“bar”] an E element whose “foo” attribute value ends exactly with the string bar
E[foo*=“bar”] an E element whose “foo” attribute value contains the substring bar
E[foo|=“en”] an E element whose “foo” attribute value is a hyphen-separated list beginning with en
E[foo~=“bar”] an E element whose “foo” attribute value is a whitespace-separated list containing bar

Structural pseudo-classes selectors

E:root an E element, root of the document
E:empty an E element that has no children (including text nodes)
E:nth-child(n) an E element, the n-th child of its parent
E:nth-of-type(n) an E element, the n-th sibling of its type
E:nth-last-child(n) an E element, the n-th child of its parent, counting from the last one
E:nth-last-of-type(n) an E element, the n-th sibling of its type, counting from the last one
E:first-child an E element, first child of its parent
E:last-child an E element, last child of its parent
E:only-child an E element, only child of its parent
E:first-of-type an E element, first sibling of its type
E:last-of-type an E element, last sibling of its type
E:only-of-type an E element, only sibling of its type

Location pseudo-classes selectors

E:any-link an E element being the source anchor of an hyper-link never visited
E:link an E element being the source anchor of an hyper-link never visited
E:local-link an E element being the source anchor of an hyper-link never visited
E:visited an E element being the source anchor of an hyper-link already visited
E:target an E element being the target of the referring URI
E:scope an E element being a designated reference element

Linguistic pseudo-classes selectors

E:dir(ltr) an element of type E with left-to-right directionality
E:lang(it) an element of type E tagged as being written in Italian

User action pseudo-classes selectors

E:active an E element during certain user actions
E:hover an E element during a mouse over action
E:focus an E element being the focus of the document
E:focus-within an E element that has user input focus or contains an element that has input focus
E:focus-visible an E element that has user input focus, and the UA has determined that a focus ring or other indicator should be drawn for that element

Multimedia state pseudo-classes selectors

* (name) avalue
:playing :paused :seeking :buffering :stalled :muted :volume-locked

Input pseudo-classes selectors
table{ border: 1px solid black; width: 100% }.
| E:enabled | a user interface element E that is enabled |
| E:disabled | a user interface element E that is disabled |
| E:indeterminate | a user interface element E that is in an indeterminate state |
| E:default | a user interface element E that is the default item in a group |
| E:checked | a user interface element E that is checked or selected (radio or checkbox) |
| E:optional | a user-input element E that does not require input |
| E:required | a user-input element E that requires input |
| E:invalid | a user-input element E that does not meets its data validity semantics |
| E:valid | a user-input element E that meets its data validity semantics |
| E:in-range | a user-input element E whose value is in-range |
| E:out-of-range | a user-input element E whose value is out-of-range |
| E:read-only | a user interface element E that is not user alterable |
| E:read-write | a user interface element E that is user alterable |

Content pseudo-element selectors (not supported)

E::after generated content after an E element
E::before generated content before an E element
E::selection portion of a document highlighted by the user
E::first-line the first formatted line of an E element
E::first-letter the first formatted letter of an E element
Clone this wiki locally