CSS pattern matching

Hey everyone, I'm curious if there's a way to apply pattern matching when selecting elements using CSS. In particular, I want to target anchor elements that contain a particular word in their href attribute, for example:
a[href="*keyword*"] {}
a[href="*keyword*"] {}
This doesn't work, but the idea is that if the word "keyword" appears in the attribute "href" it would select this element. Is this possible, or is there something equivalent to this?
2 Replies
Joao
Joao•2mo ago
Pff, as usual as soon as I ask online I find the answer right away 😫
Joao
Joao•2mo ago
As per the MDN docs https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
a[href*="keyword"] {}
a[href*="keyword"] {}
MDN Web Docs
Attribute selectors - CSS: Cascading Style Sheets | MDN
The CSS attribute selector matches elements based on the element having a given attribute explicitly set, with options for defining an attribute value or substring value match.