Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply CSS selector to attribute values being case sensitive?

If CSS and HTML are both case-insensitive languages(*), and the W3C says

The case-sensitivity of attribute names and values in selectors depends on the document language.

How can I reconcile that with attribute values being case sensitive in selectors? For instance,

div[title=TITLE] {color:green}

does not make the text green for this HTML:

<div title="title">This is a div</div>

Fiddle here.

Is this a bug in the browser? And when I say "the browser", I mean all of them. Or am I looking at an unfinished version of the CSS3 specs? Which would be strange, as the same line of text was also in the CSS2 specs here.

(*) except for some features that are explicit exceptions, like class and ID names. Note that this example does not have class or ID names.

like image 582
Mr Lister Avatar asked Dec 03 '13 14:12

Mr Lister


1 Answers

You answered your own question:

The case-sensitivity of attribute names and values in selectors depends on the document language.

But further, I believe it is because to the browser, it and IT are not the same string. They are two different things to the browser.

EDIT--- You brought up something good in your comment. Let me explain: The HTML/CSS parser reads HTML and CSS as case-insensitive. That is because they are. But attributes are not, because they are defined by the user. So, it reads them as case-sensitive. Basically, HTML and CSS are standardized. Attributes are not.

EDITED AGAIN--- HTTP methods are standardized, (I Think) thus making it not necessary for them to be case-sensitive.

like image 51
tjons Avatar answered Oct 20 '22 12:10

tjons