CSS Has Content Aware Layout
Use CSS :has() and :not(:has()) to adapt layout to child content without JavaScript, Angular bindings, or class toggles.
SKILL.mdskills/css/selectors/has-content-aware-layout/SKILL.md
GitHubCSS Has Content Aware Layout
Use this skill when CSS can react to the DOM structure on its own.
Purpose
Create layout rules that respond to child presence or quantity without JavaScript.
When to Use
Use this skill when layout depends on visible DOM content and the condition is purely visual.
Do
- keep selectors structural and readable
- use
:has()as an enhancement - keep Angular out of purely visual decisions
Do Not
- move business logic into CSS
- depend on fragile third-party DOM
- hide accessibility behavior inside selectors
Review Checklist
- The default layout works without
:has(). - The condition is purely visual.
- The selector is scoped and readable.
- Browser support was checked.
Expected Output
Return:
- The layout condition being modeled.
- The CSS selector strategy.
- The fallback/default layout.
- Browser support or testing risks.