`:has(::after)`
Can you use
:has
with a psuedo element inside of it? It's not working for me but I don't see why it wouldn't but I can't really find anything
For context, I'm trying to style a tooltip based on whether the label has a required asterisk:
5 Replies
no
Be nice if it could detect pseudo-elements, but not how it works.
What's the CSS that's adding the asteriks? If it's coming from CSS, you can target that rule.
Yea I realized that after posting this - if it has a
.required
class or something similar I can just target that like you pointed out ๐best way to do it, imo, is use an attribute selector ๐
If you have
<input type="email" required>
, you can select it with [required]
or input[required]
and add the pseudo that way ๐this has an advantage: it prevents the form from submitting if it isn't filled, due to the built-in form validation