8

I am pretty confident this is not possible. But how can I target all elements with a data attribute.

tr[data-*] //target all data's
Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291
  • 7
    I don't think is possible as far as i know with pure css. – Alex Char Oct 21 '14 at 14:20
  • Probably is possible but I'd struggle to find a use case for it. – Paulie_D Oct 21 '14 at 14:21
  • I'd like to add cursors to all the elements that have a data attribute as they will be interactive. – Jamie Hutber Oct 21 '14 at 14:23
  • have you looked at writing some javascript and targeting that way? Then at least you could specify empty and data accordingly, which would add a class on:hover? – m33bo Oct 21 '14 at 14:28
  • 1
    hmmm...looks like you can only select by **specific** attributes...not generic ones. - http://jsfiddle.net/ngghf44x/ – Paulie_D Oct 21 '14 at 14:28
  • Not sure if this might help or not, but I think it could. Using **Multiple Attributes Values** http://css-tricks.com/multiple-attribute-values/, check fiddle:http://jsfiddle.net/chriscoyier/6DAwY/37/ – dippas Oct 21 '14 at 14:41
  • Ye, I don't wan tto use js for this :) Far to much overhead for a simple thing. – Jamie Hutber Oct 21 '14 at 14:44
  • 1
    you could give all those elements an additional common attribute and target that. `` and `` and then target them with `tr[data]{..}` – Gabriele Petrioli Oct 21 '14 at 14:51

1 Answers1

0

Neither the docs on Attribute Selectors, or the docs on data attributes gives any example or a clue to a feature like this.

Instead it splicitly states that an attribute selector is composed by

[attr=value]

[attr] Represents an element with an attribute name of attr.

With variants in the equality comparision (such as "starts with", "ends with", etc) but only to the value, never on the attr name.

So, if your aim is to add a custom cursor to every data-something element, you'd need a different approach, maybe giving them specific classes.

LcSalazar
  • 16,524
  • 3
  • 37
  • 69
  • Ye, thanks for clearling this up. I had wanted to avoid adding classes to every single data-* elements. Seems over kill for me :) – Jamie Hutber Oct 21 '14 at 14:44