I know that I can target elements which have a specific attribute in CSS, for example:
input[type=text]
{
font-family: Consolas;
}
But is it possible to target elements which have an attribute of any value (except nothing i.e. when the attribute hasn’t been added to the element)?
Roughly something like:
a[rel=*]
{
color: red;
}
Which should target the first and third <a> tags in this HTML:
<a href="#" rel="eg">red text</a>
<a href="#">standard text</a>
<a href="#" rel="more">red text again</a>
I figure it’s possible because by default, cursor: pointer seems to be applied to any <a> tag which has a value for its href attribute.
The following will match any anchor tag with a
relattribute defined:http://www.w3.org/TR/CSS2/selector.html#pattern-matching
Update:
To account for the scenario @vsync mentioned, in the comment section (differentiating between emtpy/non-empty values), you could incorporate the CSS
:notpseudo-class:https://developer.mozilla.org/en-US/docs/Web/CSS/:not