[CSS2.1] Clarification on section 4.1.3 and the application of escaped newlines to identifiers.

G Talbot has a test case that implies the following CSS identifier be reconstituted by throwing out the escaped newline.

DIV
{
background-color: gre\
en;
}

However, there is nothing in the wording of the specification that implies this is true, though other browsers are clearly accepting this. Below the spec  says 1) inside of a string, which we are not. 2) cancels the meaning of special characters, which it is not, 3) allows for inserting Unicode characters, which it again is not.

There is a note that only FireFox currently supports this behavior, which I believe makes them non-compliant. My testing with Opera/Safari/IE shows that we all throw this out which is what I would expect. It would be nice to get the bug he opened against the CSS validator deleted or closed as By Design and perhaps update the test case so that it marks the appropriate compliant/non-compliant browsers as of current date.

Relevant test case:
http://gtalbot.org/BrowserBugsSection/MSIE8Bugs/escape-newline-with-backslash-inside-string.html

Relevant spec piece:
In CSS 2.1, a backslash (\) character indicates three types of character escapes.

First, inside a string<http://www.w3.org/TR/CSS21/syndata.html#strings>, 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]<http://www.w3.org/TR/CSS21/refs.html#ref-ISO10646>) character with that number, which must not be zero. (It is undefined in CSS 2.1 what happens if a style sheet does contain a character with Unicode codepoint zero.) If a character in the range [0-9a-f] follows the hexadecimal number, the end of the number needs to be made clear. There are two ways to do that:
Relevant bug against the CSS validator:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=6203

Justin Rogers [MSFT]

Received on Wednesday, 5 November 2008 18:32:49 UTC