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

Is there a native CSS replacement for :has-text()?

I see that MDN Web Docs now lists the :has() pseudo-class among others, but is there something similar to :has-text() from uBlock Origin?

span:has-text(Promoted by) {
  display: none;
}

uBlock Origin has both, so I’m wondering whether I have simply overlooked something on MDN.

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 :

Unless I’m wrong, this is not possible in CSS.

The "easiest alternative way" is to use xpath, but it’s not usable in CSS anymore:

//a[contains(text(),"Promoted by")]
//a[text()="Promoted by"] (exact match)
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