Skip to main content

Cheat Sheet

A quick reference table for comparing W3C Selectors with the SQL-like syntax used in Jelly SQL.

SQLCSSDescriptionW3C SpecificationVariants
TAG('E')EAn element of type EType SelectorELEMENT = 'E' || TAG = 'E'
ATTR('foo')[foo]An element with a "foo" attributeAttribute SelectorsATTRIBUTE('foo') || ATTR = 'foo' || ATTRIBUTE = 'foo'
ATTR('foo') = 'bar'[foo="bar"]An element whose "foo" attribute value is exactly equal to "bar"Attribute SelectorsATTRIBUTE('foo') = 'bar'
ATTR('foo') = 'bar'[foo="bar"]An element whose "foo" attribute value is exactly equal to "bar"Attribute SelectorsATTRIBUTE('foo') = 'bar'
ATTR('foo') CONTAINS 'bar'[foo~="bar"]An element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar"Attribute SelectorsATTRIBUTE('foo') CONTAINS 'bar'
ATTR('foo') LIKE 'bar%'[foo^="bar"]An element whose "foo" attribute value begins exactly with the string "bar"Attribute SelectorsATTRIBUTE('foo') LIKE '%bar'
ATTR('foo') LIKE '%bar'[foo$="bar"]An element whose "foo" attribute value ends exactly with the string "bar"Attribute SelectorsATTRIBUTE('foo') LIKE 'bar%'
ATTR('foo') LIKE 'bar'[foo*="bar"]An element whose "foo" attribute value contains the substring "bar"Attribute SelectorsATTRIBUTE('foo') LIKE 'bar' || ATTR('foo') LIKE '%bar%'
CHILD(ROOT):rootAn element, root of the documentStructural Pseudo-Classes
CHILD(2N+1):nth-child(n)An element, the n-th child of its parentStructural Pseudo-ClassesCHILD(FIRST, 2N+1)
CHILD(LAST, 2N+1):nth-last-child(n)An element, the n-th child of its parent, counting from the last oneStructural Pseudo-Classes
CHILD(2N+1) AS TYPEOF:nth-of-type(n)An element, the n-th sibling of its typeStructural Pseudo-ClassesCHILD(FIRST, 2N+1) AS TYPEOF
CHILD(LAST, 2N+1) AS TYPEOF:nth-last-of-type(n)An element, the n-th sibling of its type, counting from the last oneStructural Pseudo-Classes
CHILD():first-childAn element, first child of its parentStructural Pseudo-ClassesCHILD(FIRST)
CHILD(LAST):last-childAn element, last child of its parentStructural Pseudo-Classes
CHILD() AS TYPEOF:first-of-typeAn element, first sibling of its typeStructural Pseudo-ClassesCHILD(FIRST) AS TYPEOF
CHILD(LAST) AS TYPEOF:last-of-typeAn element, last sibling of its typeStructural Pseudo-Classes
CHILD(ONLY):only-childAn element, only child of its parentStructural Pseudo-Classes
CHILD(ONLY) AS TYPEOF:only-of-typeAn element, only sibling of its typeStructural Pseudo-Classes
CHILD(EMPTY):emptyAn element that has no children (including text nodes)Structural Pseudo-Classes
TYPEOF(LINK):linkAn element being the source anchor of a hyperlink of which the target is not yet visitedLink Pseudo-Classes
TYPEOF(VISITED):visitedAn element being the source anchor of a hyperlink of which the target is already visitedLink Pseudo-Classes
TYPEOF(ACTIVE):activeAn element during certain user actionsUser Action Pseudo-Classes
TYPEOF(HOVER):hoverAn element during certain user actionsUser Action Pseudo-Classes
TYPEOF(FOCUS):focusAn element during certain user actionsUser Action Pseudo-Classes
TYPEOF(TARGET):targetAn element being the target of the referring URITarget Pseudo-Classes
LANG('fr'):lang(fr)An element in the language "fr" (the document language specifies how language is determined)Language Pseudo-ClassesLANGUAGE('fr')
TYPEOF(ENABLED):enabledA user interface element which is enableUI Element States Pseudo-Classes
TYPEOF(DISABLED):disabledA user interface element which is disabledUI Element States Pseudo-Classes
TYPEOF(CHECKED):checkedA user interface element which is checked (for instance a radio-button or checkbox)UI Element States Pseudo-Classes
TYPEOF(FIRSTLINE)::first-lineThe first formatted lineFirst Line Pseudo-Element
TYPEOF(FIRSTLETTER)::first-letterThe first formatted letterFirst Letter Pseudo-Element
TYPEOF(BEFORE)::beforeGenerated content before an elementBefore Pseudo-Element
TYPEOF(AFTER)::afterGenerated content after an elementAfter Pseudo-Element
CLASS = 'warning'.warningAn element whose class is "warning" (the document language specifies how class is determined)Class Selectors
ID = 'myid'#myidAn element with ID equal to "myid"ID Selectors
NOT:not(s)An element that does not match simple selector sNegation Pseudo-ClassNOT LIKE || NOT EQUALS || <> || !=
TAG('F') WITHIN TAG('E')E FAn F element descendant of an E elementDescendant Combinator
TAG('F') CHILD OF TAG('E')E > FAn F element child of an E elementChild Combinator
TAG('F') NEXT TO TAG('E')E + FAn F element immediately preceded by an E elementNext-Sibling Combinator
TAG('F') SIBLING OF TAG('E')E ~ FAn F element preceded by an E elementSubsequent-Sibling Combinator