Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

display none and :has

does :has respond positively or negatively to display: none. Meaning if you have an element, with display none on it, would :has still see that there is an element present? I assume it would since there is an element there. But I might need to combine it with:

:not([style*="display: none"])

just confirming the behavior

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The display property does not change behavior of selectors, as it doesn’t change the DOM tree, so yes it would still work

like if you have

<div>
  <p>Hi</p>
</div>
div:has(p) {
  background: blue;
  padding: 5rem;
}
p {
  display: none;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading