:has() — relational pseudo-class
:has() selects an element based on its relationships with other elements. Its arguments are relative selectors evaluated against the element being tested.
CKTIS / CSS
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
:has() selects an element based on its relationships with other elements. Its arguments are relative selectors evaluated against the element being tested.
The ::highlight() pseudo-element styles text ranges registered through the CSS Custom Highlight API without adding wrapper elements. CSS defines the appearance, while JavaScript creates the ranges and registers the highlight under a name.
The :host pseudo-class lets a stylesheet inside Shadow DOM select its host element. Outside a shadow-tree context, it matches nothing.
The :host() pseudo-class selects a Shadow DOM host element when it matches the selector inside the parentheses. It operates in the context of that host’s shadow tree, letting host styles depend on a class, attribute, or another condition.
The :hover pseudo-class matches an element designated with a pointing device, such as a mouse pointer, without requiring a click. It lets you change appearance while pointing, but must not be the only way to access important content or functionality.
The #id selector matches an element by its identifier. Learn its syntax, specificity, and what ID uniqueness means for matching.
The :indeterminate pseudo-class matches controls in an indeterminate state: appropriately configured checkboxes, radio buttons in a group with no selection, and progress elements without a value attribute. It does not simply mean “unchecked”.
The :in-range pseudo-class selects controls with range limitations that violate neither the lower nor the upper bound. It does not mean that the field satisfies every validity constraint.
A pseudo-element providing an additional way to show interest in an element, for example to reveal supplementary information.
The :interest-source pseudo-class selects a source the user is currently showing interest in, not every element with interestfor.
The :interest-target pseudo-class selects a target associated with a source in which the user is currently showing interest. The association alone is insufficient.
The CSS :invalid pseudo-class matches elements that fail data-validation constraints. It can highlight invalid values or empty required fields, including before the user has interacted with them.
The :is() pseudo-class groups alternative selectors. It takes the highest argument specificity, including arguments that do not match.
The :lang() pseudo-class selects elements by their content language, including language determined from an ancestor. It enables language-specific styling without adding a lang attribute to every element.
The :last-child pseudo-class selects an element that is last among its element siblings. It tests tree position, not visual order.
The :last-of-type pseudo-class selects the last element of its type among siblings, not necessarily the last child.
The :left pseudo-class in an @page selector selects left-hand pages of a paginated document. It allows different margins, such as a larger right margin for binding. It does not select HTML elements.
The `:link` pseudo-class selects hyperlinks the browser treats as unvisited. It does not select `a` elements without an `href` attribute.
The ::marker pseudo-element styles a list item's bullet or number independently of its text. It supports a limited set of properties, including color and font properties.
The :modal pseudo-class selects elements in a modal state, not merely visible or open elements. It can style a dialog opened with showModal() while distinguishing it from a dialog opened with show().
Native CSS nesting allows rules inside rules. The & selector refers to the elements matched by the parent rule.
The selector A + B matches an element B immediately preceded by an element A with the same parent. Whitespace, text, and comments between the elements do not break this adjacency.
The :not() pseudo-class selects elements that match none of the selectors in its argument list.
The :nth-child() pseudo-class selects elements by their position among siblings. It supports An+B patterns and optional filtering with of S.