IT lexicon › Web › CSS selectors

CSS selectors

Web På svenska → Updated: 2026-05-26

Syntax for picking DOM elements. .btn (class), #id, div p (descendant), div > p (child), :hover (pseudo-class), [type="text"] (attribute).

Specificity counting: inline > #id > .class > element. Summed as (a,b,c) — highest wins. !important breaks all rules (anti-pattern). Modern selectors: :has() (parent selector, 2023 — game-changer), :is()/:where() (specificity control), :nth-child, :not(). JavaScript: document.querySelectorAll('selector') uses the same syntax. Selectors API is W3C standard.

← Back to the lexicon