<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>CSS :Has() - Tag - Technical Manual</title><link>https://manual.toulan.fun/en/tags/css-has/</link><description>CSS :Has() - Tag - Technical Manual</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Fri, 24 Nov 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://manual.toulan.fun/en/tags/css-has/" rel="self" type="application/rss+xml"/><item><title>CSS :has() Parent Selector and Relational Queries</title><link>https://manual.toulan.fun/en/css-has-parent-selector/</link><pubDate>Fri, 24 Nov 2023 00:00:00 +0000</pubDate><author><name>HenryZ</name><uri>https://nodewee.github.io/</uri><email>nodewee@gmail.com</email></author><guid>https://manual.toulan.fun/en/css-has-parent-selector/</guid><description><![CDATA[<p>Hi, I&rsquo;m HenryZ 👋.</p>
<p>In frontend development, we often encounter these requirements:</p>
<ul>
<li><strong>Parent element styles depending on child element states</strong> — Such as navigation bars where parent <code>&lt;li&gt;</code> needs to highlight based on whether child <code>&lt;a&gt;</code> has <code>.active</code>.</li>
<li><strong>Layout changes with content</strong> — For example, CSS Grid containers switching column numbers when child elements exceed a threshold.</li>
<li><strong>Interaction-driven parent styles</strong> — During form validation, parent <code>&lt;form&gt;</code> changes state based on the validity of internal <code>&lt;input&gt;</code> elements.</li>
</ul>
<p>Previously, these scenarios could only rely on <strong>JavaScript</strong>: traversing the DOM to query child elements, then manually adding classes to parent elements. This not only increased code volume but also scattered logic between CSS and JS, reducing maintainability.</p>]]></description></item></channel></rss>