I have been waiting for a good parent selector for a long time. I mean it. Until now, if I wanted to style a parent based on what it contained, I had to use JavaScript. I thought it was a bit clumsy and overkill. But :has() pseudo-class is here to fix this problem for good.
In this short tutorial, I will teach you how to use parents and siblings selectors in a few lines of CSS. No JavaScript needed! You are only making things harder for yourself if you are still doing this in JavaScript.
Feel free to comment if you have seen any weird use cases for this.
Related topics
-----------------------------------------------------
how to select parent element in CSS ,
how to use parent selector,
how to parent selectors,
parent selectors CSS,
what are parent selectors CSS,
CSS parent selectors tutorial,
parent selectors with CSS
Subscribe and never miss a beat
-----------------------------------------------------
🔔 Subscribe for more videos like this: / @optimisticweb
Learn at your own pace
-----------------------------------------------------
HTML - • Learn HTML to Build Modern Websites
CSS - • Level Up Your CSS Skills
CSS Grid Layout - • A Complete Guide to Mastering CSS Grid Lay...
CSS Masking - • CSS Masks & Creative Effects
JavaScript - • JavaScript
Connect, share, and grow
-----------------------------------------------------
YouTube: / @optimisticweb
Bluesky: https://bsky.app/profile/optimisticwe...
X (Twitter): / optimisticweb
Instagram: / optimisticweb
Facebook: / optimisticweb
CodePen: https://codepen.io/optimisticweb
#css #cssselectors #hasselector #csshas #webdevtutorial #csstutorial #csstips #cssshorts #cssforbeginners #csstricks #css3 #learncss #optimisticweb
In questa pagina del sito puoi guardare il video online Breaking Boundaries with :has() | The Game Changing CSS Trick della durata di online in buona qualità , che l'utente ha caricato Optimistic Web 02 gennaio 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 9,376 volte e gli è piaciuto 911 spettatori. Buona visione!