TBH, maybe the simplest way forward is to wrap the text in <span>
tags with a distinct class attribute. Then your CSS can directly target that class regardless of surrounding context.
If that’s an untenable solution, you might be able to target the text with advanced CSS selectors like [attribute=value]
or :nth-child()
. But to do so, the text needs to be within an element. You cannot target text alone with CSS. So you may need <span>
tags even if you can avoid class attributes.
You might instead consider implementing the text as an :after
pseudo-element. Then it’ll surely be related to an element and can be styled accordingly.