Skip to content

CSS supported selectors

Diego Perini edited this page Apr 30, 2019 · 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 combination pseudo-classes selectors

E:is(s1, s2, …) an E element matching selectors s1 and/or s2 (Matches-Any)
E:not(s1, s2, …) an E element not matching selectors s1 or s2 (Matches-None)
NOTE: the :is() pseudo-class is still named :matches() in most browsers implementation.

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

Hyper-link, Target and Language pseudo-classes selectors

E: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:lang(it) an E element having content in language “it”

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

UI element state pseudo-classes selectors

E:enabled an UI element E whose “disabled” property is set to false
E:disabled an UI element E whose “disabled” property is set to true
E:checked an UI element E whose “checked” or “selected” property is set to true (radio, checkbox, option)

WebForms and HTML5 support (optional external add-on)

E:indeterminate an UI element E whose “indeterminate” property is set to true
E:default an UI element E whose “defaultChecked” or “defaultSelected” properties are set to true
E:optional an UI element E whose “required” property is set to false
E:required an UI element E whose “required” property is set to true
E:invalid an UI element E with constraint validation that do not satisfy its constraints
E:valid an UI element E with constraint validation that satisfy its constraints
E:in-range an UI element E with constraint validation not suffering for overflow or underflow
E:out-of-range an UI element E with constraint validation suffering for overflow or underflow
E:read-only an UI element E whose “readOnly” property is set to true
E:read-write an UI element E whose “readOnly” property is set to false

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