3

I just discovered this selector in chrome developer console as an "user agent stylesheet":

input[type="radio" i], input[type="checkbox" i] { ... }

what does the "i" do? I've never seen such construction in selector before.

Thanks.

James Donnelly
  • 117,312
  • 30
  • 193
  • 198

1 Answers1

2

This is the Case-Sensitive Attribute Selector which has been introduced in the Selectors Level 4 working draft:

E[foo="bar" i]
An E element whose foo attribute value is exactly equal to any (ASCII-range) case-permutation of bar.

6.3. Case-sensitivity

By default case-sensitivity of attribute names and values in selectors depends on the document language. To match attribute values case-insensitively regardless of document language rules, the attribute selector may include the identifier i before the closing bracket (]). When this flag is present, UAs must match the attribute's value case-insensitively within the ASCII range.

Example 13

The following rule will style the frame attribute when it has a value of hsides, whether that value is represented as hsides, HSIDES, hSides, etc. even in an XML environment where attribute values are case-sensitive.

[frame=hsides i] { border-style: solid none; }

It's worth noting that browser support for this at present will be very poor if not non-existent. Existing CSS implementations which do make use of this selector are possibly using external JavaScript libraries to imitate the Selectors Level 4 definition(s).

Community
  • 1
  • 1
James Donnelly
  • 117,312
  • 30
  • 193
  • 198
  • What's the browser support for this? Doesn't seem to work in the latest Chrome: http://jsfiddle.net/zn6ygofb/ – Etheryte Sep 04 '15 at 10:55
  • @Nit probably very little. The Selectors Level 4 Working Draft also defines a parent selector (`E! > F`) which has been [in demand](http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) for a very long time. I've added a bit about browser support to my answer. – James Donnelly Sep 04 '15 at 10:56
  • 2
    @Nit: Browser support is covered in the duplicate link, which, incidentally, was where James encountered the [css4] tag [some time ago](http://meta.stackoverflow.com/questions/286087/css4-tag-misnomer-or-useful/293623#293623) :P – BoltClock Sep 04 '15 at 14:18