{
    "content": "<h1>The Parent Selector in CSS<\/h1><p>The concept of a parent selector in <a href=\"..\/css\/\">css<\/a> has been a highly requested feature for decades. Traditionally, CSS only allowed for downward traversal of the <a href=\"..\/dom\/\">dom<\/a>, meaning styles could be applied to children based on their parents, but not vice versa. The introduction of the <a href=\"..\/has-pseudo-class\/\">has-pseudo-class<\/a>, often called the relational pseudo-class, finally solved this limitation.<\/p><p>According to the <a href=\"..\/w3c\/\">w3c<\/a> specifications, the <code>:has()<\/code> selector allows an element to be selected if it contains a descendant that matches a specific criteria. As noted by <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/:has\">MDN Web Docs<\/a>, this provides a way to style a container based on its content, which is essential for modern <a href=\"..\/user-interface\/\">user-interface<\/a> patterns. For example, a card component can be highlighted only if it contains specific <a href=\"..\/html-elements\/\">html-elements<\/a> like an icon or a button.<\/p><p>Beyond simple parent-child relationships, <code>:has()<\/code> can be used with various <a href=\"..\/combinators\/\">combinators<\/a> to create complex logic. <a href=\"https:\/\/css-tricks.com\/the-css-has-selector\/\">CSS-Tricks<\/a> highlights that this selector effectively replaces many common <a href=\"..\/javascript\/\">javascript<\/a> patterns used for state-based styling. While supported in most modern <a href=\"..\/web-browser\/\">web-browser<\/a> versions, it is part of the <a href=\"..\/css-selectors-level-4\/\">css-selectors-level-4<\/a> module.<\/p><ul><li><a href=\"..\/pseudo-classes\/\">pseudo-classes<\/a><\/li><li><a href=\"..\/combinators\/\">combinators<\/a><\/li><li><a href=\"..\/dom-traversal\/\">dom-traversal<\/a><\/li><li><a href=\"..\/cascade-layers\/\">cascade-layers<\/a><\/li><\/ul>",
    "tags": [
        "css",
        "selectors",
        "has-pseudo-class",
        "parent-selector",
        "web-development",
        "frontend",
        "styling",
        "modern-css",
        "w3c",
        "dom",
        "ui-design"
    ]
}