Re: Malformed declarations incorrectly parsed?

Douglas Perreault CPA* CITP wrote:
> Now you all are confusing me <grin> ...

It is confusing, no doubt about that. :)

> I should think with 
> 
> p { color:red; color:; color:green }
> 
> That the UA should report "color:red", especially because of the statement:
> 
> "Lexical errors are handled with a skip to matching brace"

Just to be clear, that's just a rule made up by the validator developers 
for validation purposes: it directly contradicts the handling mandated 
by the specification in:

http://www.w3.org/TR/CSS21/conform.html#conformance

http://www.w3.org/TR/CSS21/syndata.html#tokenization

http://www.w3.org/TR/CSS21/grammar.html

http://www.w3.org/TR/CSS21/syndata.html#parsing-errors

To boil it down to the essentials: the spec says UAs should parse input 
CSS according to the core CSS grammar. If the input can't be parsed with 
that grammar, then how to handle the input (i.e. the whole stylesheet) 
is undefined in CSS 2.1. If the input can be parsed with that grammar, 
but isn't valid CSS 2.1 (either because it doesn't follow the more 
narrow CSS 2.1-specific grammar or because it uses unknown properties or 
illegal values), then the spec defines some forwards-compatible error 
handling rules, such as ignoring unknown properties and malformed 
declarations.

The example in question was lifted directly from the CSS 2.1 spec, which 
specifies that UAs should treat it as equivalent to:

p {
color : red;
color : green;
}

> It was always my understanding that the UA should read the styles up to the
> point it first comes across an error. From that point on everything else
> should be ignored up to the matching brace.

I'm afraid you're mistaken.

Hope that helps.
--
Benjamin Hawkes-Lewis

Received on Wednesday, 19 March 2008 14:54:59 UTC