Tell me, please, can I somehow access the span elements containing, say, certain text, using CSS and set certain styles for them?

For example:

 <span>Это красный фрукт</span> <!-- Красным шрифтом --> <span>Что по белым полоскам зебры катится</span> <!-- Белым --> <span>На светофоре свет зелёный пешеходам</span> <!-- Зелёным --> 

    2 answers 2

    On pure CSS - no way. You can set only the style for empty elements ( :empty ) and only in CSS3 .

    Recently there was the same question, it is possible only in jQuery with its Sizzle engine through this property .
    On pure CSS, this is impossible, and, if you think about it, this is not his business. CSS describes the mapping rules and it is violet to it what exactly is in these containers.
    Through JS, you can select all the elements and then check them for the necessary text - there you can even turn around with regulars, which, of course, is much better.

    • Thank! implemented on js. but if you still need to do the same, but for certain screen resolutions - how to implement it? - Vasya
    • I try to connect like this - does not work .. if (window.innerWidth <600) {document.write ('<script type = "text / javascript"> $ ('. entertain .counter_holder span.counter: contains ("98") ' ) .css ('top', '94px'); </ script> '); document.write ('<script type = "text / javascript"> $ ('. entertain .counter_holder span.counter: contains ("37") '). css (' top ',' 181px '); </ script> '); document.write ('<script type = "text / javascript"> $ ('. entertain .counter_holder span.counter: contains ("60") '). css (' top ',' 268px '); </ script> '); } - Vasya