Skip to main content
Back to All 21 Methods & AI Cheat Sheet
METHOD 07coreZero-JS Blueprint

Method #07: Relational CSS State

Dynamic Selectors (:has(), :is(), :not(), :checked)

The revolutionary CSS relational selector. Often called the parent selector, :has() enables you to style a parent container or sibling element based on the state of its descendants (e.g. coloring an entire pricing card when a radio button inside is selected) without writing a single line of JavaScript.

Primary Use: Styling parent cards based on input states, toggle switches, form validation feedback, and conditional UI with zero JavaScript.•Health: 95/100•Safety: 98/100•Speed: 100/100
METHOD 07 Core FoundationZero-JS (Pure HTML+CSS)

Relational CSS State

Dynamic Selectors (:has(), :is(), :not(), :checked)

The revolutionary CSS relational selector. Often called the parent selector, :has() enables you to style a parent container or sibling element based on the state of its descendants (e.g. coloring an entire pricing card when a radio button inside is selected) without writing a single line of JavaScript.

Code Health
95
Platform Safety
98
Zero-Bloat Score
100
Load Speed
100
Primary Use Case

Styling parent cards based on input states, toggle switches, form validation feedback, and conditional UI with zero JavaScript.

Dependency & Maintenance Assessment

Zero Dependencies · 100% Browser Native

Architectural Decision Framework

When to Choose

Definitive engineering rule for builders & AI prompt agents

When to Pick

Interactive pricing switches (monthly vs annual), active card highlighting when selected, form validation borders, and conditional UI state.

Prefer Instead

Method 09 (Client State) when the selected state must persist across page refreshes or be saved in URL parameters.

Avoid When

Data mutations that must send payloads to a backend server (use Method 08 for forms).

AI System Directive for Method #07

Use CSS relational pseudo-classes (:has(), :is(), :where(), :not()) combined with :checked or :focus-within to orchestrate UI states without JavaScript.

In Plain English

Beginner Friendly

What this actually means if you are not a developer

What It Is

CSS that reacts to what’s happening. Previously, CSS could only style elements from top to bottom. With :has(), CSS can look inside a card, see that a checkbox was clicked, and highlight the entire card border—with zero JavaScript.

Everyday Analogy

"A smart light switch that turns on room lights automatically when someone walks through the doorway."

When To Pick This

Whenever you want pricing toggles, selectable plan cards, or interactive checkable lists.

Advantages

  • •Completely eliminates class-toggling JavaScript for UI state changes
  • •Supports interactive pricing switches (monthly vs yearly) purely in CSS
  • •Instant validation styling on forms based on :valid and :invalid inputs
  • •100% browser native in all evergreen browsers

Constraints

  • •Cannot nest :has() inside another :has() (:has(:has(...)))
  • •Complex deeply chained selectors on massive DOM trees can impact paint performance

Tactical Brief

Ideal Use Cases

Monthly/annual pricing switchers, selectable plan cards, form error highlights, interactive checklist counters, and dark/light UI toggles.

Do not use deep descendant wildcard selectors (* :has(*)). Keep your relational selectors targeted: .card:has(input:checked).

Pair :has() with hidden checkbox inputs to create multi-state interactive filter bars, pricing toggles, and expandable menus completely in CSS.

Production Asset

Isolated, self-contained clean implementation

Sandboxed Runtime•100% Client Isolation

HTML AI Prompt

Dual architecture prompts tailored for AI code generation

Design an interactive pricing tier comparison with Monthly/Annual toggles using pure CSS :has() and :checked.
Constraints:
- Toggle between Monthly and Annual billing using a hidden radio button and relational CSS (:has()).
- Highlight the selected pricing card dynamically when its radio button is checked.
- Update price displays ($29/mo vs $290/yr) with pure CSS attribute selectors or :has().
- Zero JavaScript, zero external libraries.

Engineering Verification & 14KB Compliance Checklist (07)

Zero-JS Native Pattern

Before shipping code generated with Relational CSS State (Dynamic Selectors (:has(), :is(), :not(), :checked)), verify every structural constraint below in the Live HTML Editor. Maintaining a lean initial document ensures browsers decode your critical markup inside the opening 14KB TCP congestion window while preserving full semantic clarity for search crawlers and AI answer engines.

Runtime Footprint & Telemetry Target

Method 07 operates in the core tier with a dependency profile of Zero Dependencies · 100% Browser Native. Expected runtime budget is approximately 95 HTML, 98 CSS, and 100 peak payload speed.

Systeme.io & CMS Container Safety

When deploying Relational CSS State for Styling parent cards based on input states, toggle switches, form validation feedback, and conditional UI with zero JavaScript., switch to the SIO-Safe Prompt tab above so all selectors remain scoped under .sio-raw-wrapper, stacking contexts stay at or below z-index: 19, and parent builder resets cannot leak.

  • 1. First-Paint Semantics: Confirm primary headings, landmark tags, and core copy render immediately without waiting for deferred scripts or third-party hydration.
  • 2. Zero Layout Shift (CLS ≤ 0.01): Reserve explicit width, height, or CSS aspect-ratio bounds on media containers, dynamic drawers, and embedded canvases prior to execution.
  • 3. Isolated Execution: This architecture relies strictly on native HTML5 elements and GPU-accelerated CSS rules with zero JavaScript execution overhead.

AI Engine Optimization (AEO) Readability

Search bots and LLM crawlers index Relational CSS State components best when visible text lives directly inside standard semantic elements rather than JavaScript template strings. Always keep essential copy, labels, and structured metadata intact in initial HTML so Google, Gemini, Claude, and Perplexity extract your page context immediately on static fetch.

Pre-Publish Sandbox Inspection

Open your generated Dynamic Selectors (:has(), :is(), :not(), :checked) snippet inside the Live HTML Editor before publishing to any live domain. Confirm keyboard focus outlines remain visible, interactive states respect reduced-motion preferences, and compressed HTML plus CSS overhead stays lean enough to render cleanly in a single mobile network roundtrip.

Long-Term Browser Stability & Caching: All blueprints implementing Relational CSS State avoid experimental APIs without graceful CSS fallbacks, allowing evergreen Chromium, WebKit, and Gecko browsers to cache and render components deterministically with zero external polyfill overhead or recurring security maintenance. Clean HTML delivery also ensures instant first paint across low-bandwidth cellular links without blocking script evaluation.

Continue Exploring

Apply Method #07 Across Your Stack

Test your generated code live in our browser editor or grab the complete 21-method AI system prompt constitution.