0

CSS style based on tag content

Hello everybody! Is it possible to do different for example text colours dependent on what’s tag contains? I mean If tag <a> contains(text) “login” it is red coloured But if <a> contains(text) “logout” it is blue coloured Text inside “” is just text, not classes, ids. Please do not show me JavaScript examples, I want to handle this by just css, best regards, Eterxoz

6th Jan 2019, 12:47 AM
Eterxoz
Eterxoz - avatar
5 Answers
+ 1
Just add id atrributes of login and logout, set the css selectors accordingly.
6th Jan 2019, 5:11 AM
CalviŐ˛
CalviŐ˛ - avatar
+ 1
Eterxoz I know that you look for css to check for text content, unfortunately it's not possible for css to check for text node now.
6th Jan 2019, 10:47 AM
CalviŐ˛
CalviŐ˛ - avatar
0
CalviŐ˛ Thanks for help, but as i mentioned i want different styles based on content, not id/classes.
6th Jan 2019, 10:20 AM
Eterxoz
Eterxoz - avatar
0
Eterxoz for your study, using JavaScript is another option. https://code.sololearn.com/Wc6q6gha2q4L/?ref=app
6th Jan 2019, 10:33 AM
CalviŐ˛
CalviŐ˛ - avatar
0
Calviղ I know javascript is an another option. Just wondering if it is possible with just css. I found something like „contains” pseudoclass, but in documentations it is not explained in any proper way. Just an space with „to be filled” is left. Anyway thanks for help! for others: It is not possible yet(06.01.2019). best regards, Eterxoz
6th Jan 2019, 12:07 PM
Eterxoz
Eterxoz - avatar