IT lexicon › Web › :has() selector

:has() selector

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

CSS selector that matches an element's parent based on its children — the long-awaited "parent selector".

article:has(img) picks <article> elements containing an image. li:has(> ul) = a list item with a submenu. Available since 2023 in all modern browsers. Replaces piles of JavaScript tricks.

← Back to the lexicon