Skip to main content

CSS Selectors

Selectors supported by Sciter

CSS 2.1 and CSS 3 selectors

PatternRepresentsDescription
*any elementUniversal selector
Ean element of type EType selector
E[foo]an E element with a "foo" attributeAttribute selectors
E[foo="bar"]an E element whose "foo" attribute value is exactly equal to "bar"Attribute selectors
E[foo~="bar"]an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar"Attribute selectors
E[foo^="bar"]an E element whose "foo" attribute value begins exactly with the string "bar"Attribute selectors
E[foo$="bar"]an E element whose "foo" attribute value ends exactly with the string "bar"Attribute selectors
E[foo*="bar"]an E element whose "foo" attribute value contains the substring "bar"Attribute selectors
E[foo|="en"]an E element whose "foo" attribute has a hyphen-separated list of values beginning (from the left) with "en"Attribute selectors
E:rootan E element, root of the documentStructural pseudo-classes
E:nth-child(n)an E element, the n-th child of its parentStructural pseudo-classes
E:nth-last-child(n)an E element, the n-th child of its parent, counting from the last oneStructural pseudo-classes
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural pseudo-classes
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting from the last oneStructural pseudo-classes
E:first-childan E element, first child of its parentStructural pseudo-classes
E:last-childan E element, last child of its parentStructural pseudo-classes
E:first-of-typean E element, first sibling of its typeStructural pseudo-classes
E:last-of-typean E element, last sibling of its typeStructural pseudo-classes
E:only-childan E element, only child of its parentStructural pseudo-classes
E:only-of-typean E element, only sibling of its typeStructural pseudo-classes
E:emptyan E element that has no children (including text nodes)Structural pseudo-classes
E:link E:visitedan E element being the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited)The link pseudo-classes
E:lang(fr)an element of type E in language "fr" (the document language specifies how language is determined)The :lang() pseudo-class
E::beforegenerated content before an E elementThe ::before pseudo-element
E::aftergenerated content after an E elementThe ::after pseudo-element
E.warningan E element whose class is "warning" (the document language specifies how class is determined).Class selectors
E#myidan E element with ID equal to "myid".ID selectors
E:not(s)an E element that does not match simple selector sNegation pseudo-class
E Fan F element descendant of an E elementDescendant combinator
E > Fan F element child of an E elementChild combinator
E + Fan F element immediately preceded by an E elementNext-sibling combinator
E ~ Fan F element preceded by an E elementSubsequent-sibling combinator

Sciter shortcut selectors

PatternRepresents
E(name)Equivalent of E[name="name"]
E|nameEquivalent of E[type="name"]

State CSS selectors

These selectors are reflected in JavaScript as element.state.xxx.

Some of them are set by runtime only and some are allowed to be set by JS.

PatternMatchesJS
E:emptyan element that has no children or <input> elements with no value setelement.state.empty
E:activemouse/touch pressed on an elementelement.state.active
E:hovermouse is inside an elementelement.state.hover
E:focusan E element is in focuselement.state.focus
E:tab-focusan E element got focus by TAB traversalelement.state.tabfocus
E:owns-focusan E element has focused descendant inside itelement.state.ownsfocus
E:focusablean E element is focusableelement.state.focusable
E:linkan E element has behavior:hyperlinkelement.state.link
E:visitednot used by Sciter, but JS code can set itelement.state.visited
E:checkedan element is checked (for instance a radio-button, checkbox or option)element.state.checked
E:currentan element is current (for instance an option in select)element.state.current
E:disabledan element is disabledelement.state.disabled
E:read-onlyan element is read only (for instance textarea or htmlarea)element.state.readonly
E:expandedan element is expanded (option in select|tree)element.state.expanded
E:collapsedan element is collapsed (option in select|tree), element can have either :expanded or :collapsed flag setelement.state.collapsed
E:nodean element is an expandable/collapsible node option in select|treeelement.state.node
E:incompletean element is incomplete (img or frame has no content arrived )element.state.incomplete
E:busyan element is busy (img or frame is loading )element.state.busy
E:invalidinput element has an invalid valueelement.state.invalid
E:animatingan element has running transition or animation (including scroll) on itelement.state.animating
E:popupan element is shown as a popup nowelement.state.popup
E:owns-popupan E element has popup shown for it by E.popup(popupEl)element.state.ownspopup
E:drag-overdrag over an E elementelement.state.dragover
E:drag-sourcean E element is a drag source, see window.performDrag()element.state.dragsource
E:drop-targetnot used intenaly, for JS use onlyelement.state.droptarget
E:ltran element is in LTR environmentelement.state.isltr
E:rtlan element is in RTL environmentelement.state.isltr
E:theme(A)an E element or one of its parents has theme="A-B" or theme="B-A" attribute definedN/A
E:window-rootan E element is a window root - either root document of the window or a popup element that has window created for itN/A
E:blur-behinda :window-root element that uses blur-behind backgroundN/A
tip

At runtime these state flags can be set by JS as

element.state.visited = true;

for example.

tip

In JSX these state flags can be set at attributes by prepending "state-" to the names above:

render() {
return <div state-visited={true}>...</div>
}