CSS rule based on content [duplicate]
No. :contains
was once proposed but is not in the current Working Draft of CSS3 Selectors.
You would need some JavaScript, for example:
for (var i= document.links.length; i-->0;)
if (/\bSpecificWord\b/i.test(document.links[i].innerHTML)
document.links[i].style.color= 'red';
You can match attribute values though. If you use custom data attributes, it might get what you want.
yes there is a :contains
selector in CSS3.
li:contains("special"){text-style: italic;}
it is mentioned about 1/2 down this page here
This is something you can also do with jQuery too ...
@bobince help me and I wrote this code:
var x = document.getElementsByTagName('TD');
for (var i= x.length; i-->0;)
if (x[i].innerHTML=='closed')
x[i].parentNode.style.background= '#FEE';
If the content of some TD is 'closed' then the background color of the TR will be identified with light red color.