W3C home > Mailing lists > Public > www-style@w3.org > March 2001

Re: Token question

From: Peter S. Linss <peter@linss.com>
Date: Fri, 02 Mar 2001 17:35:40 -0800
Message-ID: <3AA04A6C.CB11F3E0@linss.com>
To: Eric Meyer <emeyer@theopalgroup.com>
CC: www-style@w3.org
The token is essentially the smallest unit in the CSS grammar. As an
analogy, in English, the tokens are: words, numbers, spaces, punctuation,
etc.

In your example the tokens are (note that various tokenizer/paser pair may
use different granularity, this is what Mozilla uses):
'h1': an IDENT
' ': a whitespace
'{': a punctuation
'color': an IDENT
':': a punctuation
' ': a whitespace
'/* tan */': a comment, effectively a whitespace
' ': a whitespace (?, or possibly a linebreak, can't tell from your mail,
and doesn't matter anyway, it's still whitespace)
'#FFCC66': a HASH (there are special cases of these for colors)
';': a punctuation
'}': a punctuation

And to answer the original question, no, the browser should not have
ignored the CSS, it is perfectly valid.

Eric Meyer wrote:

>     In response to a question e-mailed to me, I've found I need to
> know exactly what constitute tokens in CSS.  Not being a programmer,
> the specification doesn't make it easy to find out so I figured
> somebody here could tell me.
>     Basically, the question was: "I wrote 'h1 {color: /* tan */
> #FFCC66;}' and it was ignored by my browser.  Why?"  So I went and
> looked up comments, and discovered that they may "appear anywhere
> between other tokens" (CSS2:4.1.1).  So should the browser have
> ignored what the user wrote?  Is a declaration the smallest token, or
> are property and value separate tokens?  Inquiring minds want to
> know...
>
> --
> Eric Meyer
> Internet Applications Manager          e-mail: emeyer@theopalgroup.com
> The OPAL Group / Technical Services     voice: (216) 986-0710 ext. 21
>   http://www.theopalgroup.com/             fax: (216) 986-0714
Received on Friday, 2 March 2001 20:36:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:08 GMT