CSS selector case insensitive for attributes

Alp picture Alp · Apr 15, 2011 · Viewed 24.3k times · Source

If I have an HTML element <input type="submit" value="Search" /> a css selector needs to be case-sensitive:

input[value='Search'] matches

input[value='search'] does not match

I need a solution where the case-insensitive approach works too. I am using Selenium 2 and Jquery, so answers for both are welcome.

Answer

Robert Siemer picture Robert Siemer · Nov 3, 2014

CSS4 (CSS Selector Level 4) adds support for it:

input[value='search' i]

It's the "i" at the end which does the trick.

Broader adoption started mid-2016: Chrome (since v49), Firefox (from v47?), Opera and some others have it. IE not and Edge since it uses Blink. See “Can I use”...