Use :has() to style parent elements based on their descendants
SkillDev toolshas-selector is a skill that guides an AI agent through reviewing stylesheets and components to find JavaScript that toggles classes on parent elements. It checks whether the CSS :has() pseudo-class could replace that JavaScript, explains how :has() works, and compares it with related selectors like :is() and :not().
Use Use :has() to style parent elements based on their descendants in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Use :has() to style parent elements based on their descendants and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Use :has() to style parent elements based on their descendants skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; ahel provides instructions and does not run this skill.
No other account needed.
Have an agent that can load and use skills.
What your AI can do with it
- Identify JavaScript class-toggling that the :has() pseudo-class could replace
- Explain how :has() works and when it applies to parent-element styling
- Compare :has() with related selectors such as :is() and :not()
- Note browser support for :has()
- Warn about layout-performance costs of :has() selectors
Getting started
- Have an agent that can load and use skills.
- Add the has-selector skill to the agent's available skills.
- Ask the agent to review a stylesheet or component that uses JavaScript to toggle classes on parent elements.
- The agent applies the skill to check whether :has() can replace the JavaScript and reports its findings.
What this skill tells your AI
The instructions your AI receives, as published by thedaviddias/front-end-checklist in skills/has-selector/SKILL.md and read by ahel’s review.
Before :has(), styling a parent based on its children required JavaScript: detecting state, toggling classes, and keeping DOM and styles in sync. This created coupling between styling logic and application logic. :has() moves that relationship back into CSS where it belongs, reducing JavaScript complexity, eliminating class-toggling boilerplate, and making styling intent readable in the stylesheet itself.
Quick Reference
- :has() selects an element when a matching descendant exists inside it
- It is the parent selector CSS has needed for decades
- Baseline support since late 2023 — all major browsers include it
- Avoid complex :has() selectors in hot reflow paths — they can affect layout performance
Check
Look for patterns in this code where JavaScript toggles a class on a parent element based on the state or content of a child element. These are candidates for replacement with :has().
Fix
Replace the JavaScript class-toggling logic with a CSS :has() selector. Show the selector that targets the parent element when the relevant child condition is met.
Explain
Explain how the :has() pseudo-class works, how it differs from :is() and :not(), what descendant vs child combinators mean inside :has(), and how browser support stands today.
Code Review
Review the stylesheets and component JavaScript in this file. Flag any locations where a parent element's style is controlled by toggling a class from JavaScript based on child state — and show the equivalent :has() rule.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/en/rules/css/has-selector
Signals
- GitHub stars
- 74k
- Forks
- 7k
- Last commit
- Oct 2026
Questions
- When should this skill be used?
- When reviewing stylesheets or components that use JavaScript to toggle classes on parent elements based on child state, form input values, or content presence, :has() may replace the JavaScript entirely.
- Does :has() work in all browsers?
- The skill covers browser support for :has(), so the agent can report which browsers support it during a review.
- Are there performance concerns with :has()?
- Yes. The skill warns about layout-performance costs when using :has() selectors.
Advanced
- Item type
- skill
- Key
has-selector- Source
- github.com/thedaviddias/front-end-checklist
github.com/thedaviddias/front-end-checklist