has-selector
What it does
This skill looks for code that uses JavaScript to change a parent's style based on what its children contain. It is for developers who want simpler, CSS-based styling.
When to use it
- ✓When your script adds a class to a container whenever an input inside it changes.
- ✓When you write JavaScript only to style a parent based on its content.
- ✓When you want to cut down on styling code that is hard to keep in sync.
Skill link
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/has-selector/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can I use CSS instead of JavaScript to style a parent when its child changes?”
5 new skills a week. 1 minute to read.
How it works
The agent finds JavaScript that toggles parent classes and suggests a :has selector that targets the parent when the child condition is met. It also explains how :has differs from :is and :not.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Use :has() to style parent elements based on their descendants
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/rules/css/has-selector
FAQ
What does :has do?
It selects an element when a matching child or descendant exists inside it, which CSS could not do before.
Is it widely supported?
The skill says :has has baseline support in all major browsers since late 2023.
Can it slow the page down?
The skill warns against complex :has selectors in frequently recalculated layout areas.
Details
Original description by the author
Use 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.
Popularity
- GitHub stars
- 75k
- Ranking position
- #2865
- License
- MIT
- Updated
- 10/31/2026
Comments
- …
More skills from this repository
frontendchecklist
75kChecks frontend code and live pages against 380+ rules for accessibility, speed, SEO and security, using a command-line tool.
frontend-checklist-global
75kAudits a frontend project against all 386 Front-End Checklist rules, and gives a specific fix for each issue found.
404-page
75kChecks that your missing-page screen offers helpful links and returns a real 404 status, to help lost visitors find their way.
about-page
75kReviews whether your site has a clear About page that explains who runs it, to build trust with visitors and search engines.
Similar skills
angular-developer
280kHelps your agent create Angular code and give project structure advice. Useful for starting new projects, creating code parts, or improving performance and accessibility.
frontend-a11y
280kHelps your agent make web interfaces accessible to everyone. It ensures websites and apps work well with screen readers and keyboard navigation.
frontend-patterns
280kHas your agent apply modern patterns in frontend development. It optimizes performance, manages state, and follows best practices in React and Next.js.