CSS style based on tag content | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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