W3C home > Mailing lists > Public > www-style@w3.org > January 2013

case sensitivity of attribute value selector matching [was Re: Case sensitivity in CSS: some tests]

From: John Daggett <jdaggett@mozilla.com>
Date: Thu, 10 Jan 2013 17:54:05 -0800 (PST)
To: www-style@w3.org
Message-ID: <685371467.10420785.1357869245317.JavaMail.root@mozilla.com>
Boris Zbarsky wrote:

> > Selectors and HTML attribute values do NOT match where case is
> > different.
> 
> This depends on the attribute name, no?  At least in some UAs...

Just to follow up on this a bit, what Boris is describing here is the
way the HTML4 spec describes matching of attribute values, each
attribute is labeled either as CS (case sensitive) or CI (case
insensitive).  For example, the 'lang' attribute is CI [1], the
'title' attribute is CS [2].  Unfortunately, the precise definition of
"case insensitive" isn't spelled out, which is the reason user agents
differ here [3].  The complete list of attributes whose values are
compared case insensitively within Gecko code:

  http://hg.mozilla.org/mozilla-central/file/f60b87eed1ac/layout/style/nsCSSParser.cpp#l3338

I've updated my class/id/attribute selector test to show both types
of attributes:

  http://people.mozilla.org/~jdaggett/tests/casesensitivity-classid.html 

The HTML5 spec eliminates the distinction between different
attributes, *all* attribute values are matched case sensitively [4]:

  Attribute and element names of HTML elements in HTML
  documents must be treated as ASCII case-insensitive for
  the purposes of selector matching.

  Everything else (attribute values on HTML elements, IDs
  and classes in no-quirks mode and limited-quirks mode, and
  element names, attribute names, and attribute values in
  XML documents) must be treated as case-sensitive for the
  purposes of selector matching.

Current user agents all handle attribute value selector matching the
HTML4 way, with differences in the precise "case insensitive"
algorithm used.  Firefox uses ASCII case insensitivity while
Opera/Chrome/IE each use a slightly different flavor of Unicode case
insensitivity.  Attribute values matched case sensitively are handled
consistently across user agents.

Regards,

John Daggett

[1] http://www.w3.org/TR/html4/struct/dirlang.html#h-8.1
[2] http://www.w3.org/TR/html4/struct/global.html#h-7.4.3
[3] http://www.w3.org/TR/html4/types.html#h-6.1
[4] http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#case-sensitivity
Received on Friday, 11 January 2013 01:54:32 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:04 GMT