Reputation: 4200
I have this markup:
<p class='[&_a]:text-[red]'><a>hi</a> world</p>
This code adds styles to all a
tags within p
tag, but i want to add the class to all elements regardless of the fact that it is a
, 'div`,or anything else. I tried to do this:
<p class='[&_*]:text-[red]'><a>hi</a> world</p>
but it does not work.
How can I achieve what I described above?
Upvotes: 2
Views: 2988
Reputation: 11
If I understand correctly, you want to style all children of your <p>
element.
CSS styles are inherited by all children elements by default.
You can use text-red
class directly on your <p>
element without any variant.
Upvotes: 0
Reputation: 5667
"world" is not a child element. If you want to color it, you should use this class :
class="text-[red] [&_*]:text-[red]"
Upvotes: 3