Skip to main content

Pseudo Classes

Pseudo classes are used to target elements based on their state or position in the DOM tree. They allow you to select elements based on their relationship with other elements, such as their parent, sibling, or child elements.

All pseudo classes are used with the TYPEOF function to target elements based on their type.

Quick Reference

SQL KeywordCSSDescription
EMPTY:emptyAn element that has no children (including text nodes)
LINK:linkAn element being the source anchor of a hyperlink of which the target is not yet visited
VISITED:visitedAn element being the source anchor of a hyperlink of which the target is already visited
HOVER:hoverAn element that is being hovered over by the mouse pointer
ACTIVE:activeAn element that is being activated by the user
HOVER:hoverAn element that is being hovered over by the mouse pointer
FOCUS:focusAn element that has received focus
TARGET:targetAn element being the target of the referring URI
ENABLED:enabledA user interface element that is enabled
DISABLED:disabledA user interface element that is disabled
CHECKED:checkedA user interface element that is checked (for instance a radio-button or checkbox)
FIRSTLINE::first-lineThe first formatted line of an element
FIRSTLETTER::first-letterThe first formatted letter of an element
BEFORE::beforeThe content inserted before an element
AFTER::afterThe content inserted after an element

The TYPEOF Function

The TYPEOF function is defined as TYPEOF(<keyword>).

Here's an example to illustrate:

SELECT * FROM DOM WHERE
TAG('p') AND TYPEOF(ENABLED)

In this example:

  • The SQL query selects <p> elements that are enabled.
  • The CSS selector applies styles to <p> elements that are enabled.