Hello, let's say there is a link:

a { color: black; } a:before { content: '!'; } 
 <a href="url">text</a> 

And there are several such links. There is a task to make the text color in :before multi-colored (each link has its own) before output (in php).

How can this be done? I was thinking of something like <a href="url" style="this::before{color: red;}">text</a> but it does not work.

    1 answer 1

    Cannot pass style for pseudo-element in style attribute. This is due to the fact that the style specifies the styles for the current element, and a:before is a pseudo-element, and it does not correspond to element a .

    Alternatively, I recommend creating classes for each style, and assigning each class its own class. And the classes already implement styles for the pseudo-element :before