Menu

#3 4.1.3 Characters and case

Partially_Completed
open
nobody
Syntax (14)
2
2005-08-06
2005-08-06
Matt
No

The following rules always hold:

All CSS style sheets are case-insensitive, except for
parts that are not under the control of CSS. For
example, the case-sensitivity of values of the HTML
attributes "id" and "class", of font names, and of URIs
lies outside the scope of this specification. Note in
particular that element names are case-insensitive in
HTML, but case-sensitive in XML.
In CSS2, identifiers (including element names, classes,
and IDs in selectors) can contain only the characters [A-
Za-z0-9] and ISO 10646 characters 161 and higher, plus
the hyphen (-); they cannot start with a hyphen or a
digit. They can also contain escaped characters and
any ISO 10646 character as a numeric code (see next
item). For instance, the identifier "B&W?" may be
written as "B\&W\?" or "B\26 W\3F".
Note that Unicode is code-by-code equivalent to ISO
10646 (see [UNICODE] and [ISO10646]).

In CSS2, a backslash (\) character indicates three
types of character escapes.
First, inside a string, a backslash followed by a newline
is ignored (i.e., the string is deemed not to contain
either the backslash or the newline).

Second, it cancels the meaning of special CSS
characters. Any character (except a hexadecimal digit)
can be escaped with a backslash to remove its special
meaning. For example, "\"" is a string consisting of one
double quote. Style sheet preprocessors must not
remove these backslashes from a style sheet since that
would change the style sheet's meaning.

Third, backslash escapes allow authors to refer to
characters they can't easily put in a document. In this
case, the backslash is followed by at most six
hexadecimal digits (0..9A..F), which stand for the ISO
10646 ([ISO10646]) character with that number. If a digit
or letter follows the hexadecimal number, the end of the
number needs to be made clear. There are two ways to
do that:

with a space (or other whitespace character): "\26 B"
("&B")
by providing exactly 6 hexadecimal digits: "\000026B"
("&B")
In fact, these two methods may be combined. Only one
whitespace character is ignored after a hexadecimal
escape. Note that this means that a "real" space after
the escape sequence must itself either be escaped or
doubled.

Backslash escapes are always considered to be part of
an identifier or a string (i.e., "\7B" is not punctuation,
even though "{" is, and "\32" is allowed at the start of a
class name, even though "2" is not).

Discussion

  • Matt

    Matt - 2005-08-06

    Logged In: YES
    user_id=1307954

    The parser is partially compliant with the CSS2 standard.
    First off, it can accept any class or ID that does not interfere
    with the normal operation of the CSS2 standard. This means
    that even if an ID or class contains invalid characters such
    as / or &, it will still be able to parse them and pass them
    along as a whole. For example, "B&W?" could be used and
    the parser would remain unaffected. However, the
    substitute "B\&W\?" (suppose as a class) would search for
    the class directly entitled "B\&W\?". This means that even
    though the characters are supported, "B\&W\?" will not look
    for "B&W?" in the CSS.

    We are working on this problem.

     
  • Matt

    Matt - 2005-08-06
    • milestone: 515690 --> Partially_Completed
    • priority: 5 --> 2
     

Log in to post a comment.

MongoDB Logo MongoDB