W3C home > Mailing lists > Public > www-style@w3.org > February 2011

[CSS21] Escaping characters (comment, editorial)

From: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
Date: Sun, 20 Feb 2011 18:14:40 +0100
To: www-style@w3.org
Message-ID: <20110220181440105351.85b7191c@xn--mlform-iua.no>
This is a comment on: 
http://www.w3.org/Style/css2-updates/css2/syndata.html#characters (The 
deadline for CSS21 last call comments is over, but nevertheless ...) It 
is only a editorial comment. I first outline the (small) changes. 
Thereafter I justify.

CHANGES IN '4.1.3 Characters and case':

  Add these two sentences in the beginning of 3rd list item:
    "A CSS backslash escape is an alternative way to represent a
     character. For some characters, the use of a backslash escape
     cancels an effect that the character otherwise has. CSS has
     two types of backslash escapes: plain backslash escapes and 
     hexadecimal backslash escapes."

  For the sentence (currently the beginning of 3rd list item):
     "In CSSĀ 2.1, a backslash (\) character can indicate one of three
      types of character escape."
  Replace "backlash (\) character" with "backslash (\) escape"
  and delete "types of" and add "use cases" as last words:
     "In CSSĀ 2.1, a backslash (\) escape can indicate one of three
      character escape use cases."

  For the sentence:
    "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)."
  Insert the wording "backslash newline escape" etc:
    "First, inside a string, a plain backslash newline escape (backslash
     followed by newline) cancels the meaning of the newline so that
     the string is deemed to not contain whether backslash or newline."

  For the sentence:
    "Second, it cancels the meaning of special CSS characters."
  Replace "it cancels" with "using plain backslash escapes to cancel":
    "Second, using plain backslash escapes to cancel the meaning of 
     CSS characters."

  Add note about what "special CSS characters" means:
    "Special characters include all characters that have syntactic
     meaning in CSS: quotes, combinators, characters that have special 
     meaning inside CSS indentifiers and characters that cannot appear
     unescaped inside CSS identifiers." 
     [Are there other special characters?]

  Add, at the end of the the paragraph which begins "Second, it 
  the following note:
    "Note that even hexadecimal backslash escapes (see next paragraph)
     cancel the meaning of special CSS characters."

  Add, att the end of the paragraph which begins "Third, backslash 
  allow authors to refer to characters they cannot easily put in a 
  document", the following note:
    "Note that even plain backslash escapes can sometimes be used to 
     escape charactars which the document somehow prevents from being 
     typed directly. In the following example from inside a 'style'
     element in a HTML document, the "/" is escaped to prevent the 
     'style' element from being prematurely ended:
       <style type="text/css">
         div::before { content: "<style><\/style>"; }


* The above changes are meant to
  a) make it clearer that each of the 3 types of backslash 
     escapes really aren't  types but use cases.
  b) that both 'plain backslash escapes' and 'hexadecimal 
     backslash escapes' are "alternative way to represent
     a character".
  c) that both plain and hexadecimal backslash escapes thus can
     be used to cancel meaning, and that both method can be ued
     to insert characters that are difficult to insert.
  d) explain what a "special CSS character" is. 

With regard to the explain what "special CSS character" is, then Webkit 
already has a bug in that it treats \*{} identical to *{}. As well as 
\*|*{} identical to *|*{}. See my test case message about this. [1]

When thinking about it, I found that Webkit's interpretation isn't 
taken 100% out of the air - it makes some sence, even if it si wrong - 
see [1].

CSS21 says that the "\" character "cancels the meaning of special CSS 
characters".  The wording "meaning of special CSS characters" is not 
very clear. For example, is the "-" character, is not a "special CSS 
character"? At least it is not a combinator. The only way it is 
"special" is that it is not permitted as the first character in what 
CSS3 refers to as "type selectors". THus: -{/*unpermitted*/} But 
\-{/*unpermitted*/}. The proposed changes above meaks clearer what a 
'special CSS character' is.


leif halvard silli
Received on Sunday, 20 February 2011 17:15:15 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:56 UTC