CSS WG Blog Case-Insensitivity in CSS

This is a page from the Cascading Style Sheets Working Group Blog. Some other places to find information are the “current work” page, the www-style mailing list, the Future of CSS syndicator, and the issue list on Github.

Do you want to know how the CSS WG works? Fantasai has written about:csswg, An Inside View of the CSS Working Group at W3C.

Case-Insensitivity in CSS

By fantasai December 12, 2007 (Permalink)
Categories: general i18n

Case-insensitivity in CSS is currently not precisely defined. The meaning of “case-insensitive” is pretty obvious in ASCII, but it’s not so obvious in Unicode. Some characters map differently based on the locale, some characters can’t round-trip a case mapping operation so you get different matches depending on whether you map to lowercase, uppercase, or “case-fold” case, etc.

There was a recent discussion about this problem on www-style. Martin best summarized the problem and its constraints in his message on November 8th.

There are two issues here:

  1. What the case mapping should be for CSS-defined identifiers such as property and keyword names.
  2. What the case mapping should be for user-defined identifiers such as counters and page names.

For the first issue, since CSS-defined identifiers only use characters
in the ASCII range anyway, ASCII case-insensitivity would be sufficient.
It would also prevent strings containing characters outside the ASCII
range from unexpectedly matching CSS keywords (which could cause
security problems).

For the second issue, we could adopt the Unicode case-folding algorithm,
which is at least well-defined. However a test shows that
implementations already treat counter names as case-sensitive. This is
interoperable across all four major CSS counters implementations:
Firefox, Opera, Safari, and PrinceXML (an HTML/XML + CSS -> PDF
converter).
Also because it’s much more straightforward than case-insensitivity in
Unicode, case-sensitivity is more likely to be interoperable going forward.
The downside is that case-sensitive counters could be more confusing for
authors used to case-insensitive CSS.

The CSS Working Group proposes to adopt the following changes:

  1. “All CSS style sheets are case-insensitive” -> “All CSS syntax is case-insensitive within the ASCII range (i.e. [a-z] and [A-Z] are equivalent)”
  2. “Counters are denoted by identifiers” -> “Counters are denoted by case-sensitive identifiers”

These would

  1. Define case-insensitivity of CSS-defined identifiers as ASCII
    case-insensitivity: i.e. a-z and A-Z match, but no other
    characters outside that range will ever map into that range.
  2. Define counter names as case-sensitive in CSS2.1, which would
    also set case-sensitivity as the precedent for user-defined
    identifiers introduced in future specs.

Unless there are objections that cause us to reconsider, we plan to
formally resolve this issue on 8 January 2008. Please send any comments
before then.

Discuss on www-style

« Previous article Next article »

[Photo: group photo of the CSS working group in San Francisco] Contact: Bert Bos
Copyright © 2020 W3C®

Last updated 2007-12-12 21:17:29