/compat/css/css-has-selector-support
CSS :has() browser support
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated 2026-10-20
- tool
- CSS
- versions
- Selectors Level 4
- os
- any
:has() selects an element based on its descendants or following siblings, for example .card:has(img) or label:has(+ input:invalid). It is supported in Chrome and Edge 105+, Safari 15.4+, Firefox 121+ and Samsung Internet 20+, which covers every current major browser.
Support data
Read straight from MDN's browser-compat-data package, the data behind MDN's compatibility tables:
npm init -y >/dev/null
npm install --silent --no-audit --no-fund @mdn/browser-compat-data >/dev/null 2>&1
node -e '
const bcd = require("@mdn/browser-compat-data");
const support = bcd.css.selectors.has.__compat.support;
for (const b of ["chrome", "edge", "firefox", "safari", "safari_ios", "chrome_android", "samsunginternet_android", "opera"]) {
const entry = [].concat(support[b])[0];
console.log(b.padEnd(24), entry.version_added);
}'Output
chrome 105 edge 105 firefox 121 safari 15.4 safari_ios 15.4 chrome_android 105 samsunginternet_android 20.0 opera 91
Feature detection
.form-row { border-color: #ccc; }
@supports selector(:has(a)) {
.form-row:has(input:invalid) { border-color: crimson; }
}Examples
/* a card that contains an image gets a different layout */
.card:has(img) { grid-template-columns: 8rem 1fr; }
/* style a label whose following input is invalid */
label:has(+ input:invalid) { color: crimson; }
/* page-level state: lock scroll while a dialog is open */
body:has(dialog[open]) { overflow: hidden; }Sources
Related pages
cheat sheets · cssCSS flexbox cheat sheet: container and item propertiesCSS flexbox cheat sheet: display flex, flex-direction, justify-content, align-items, flex-wrap and gap on the container; flex, align-self, order on items.compare · cssCSS em vs rem: which unit to userem is relative to the root font size, so 1rem is the same everywhere; em is relative to the element's font size and compounds when nested. When to use each.changes · tailwindcssTailwind CSS v3 to v4: renamed utilities and breaking changesTailwind CSS v4 moves config into CSS with @import and @theme, splits the PostCSS plugin and CLI, renames shadow, blur and rounded scales, needs Safari 16.4.