- From: L. David Baron <dbaron@dbaron.org>
- Date: Sat, 6 Feb 2010 23:43:14 -0800
- To: www-style <www-style@w3.org>
On Saturday 2010-02-06 23:02 -0800, Andrew Fedoniouk wrote: > Grammar of all properties in CSS 2.1. obey this simple set of rules: > > <VALUE_OR_PAIR> > : <VALUE> > | <VALUE> "/" <VALUE> > > <VALUE_COMMA_LIST> > : <VALUE_OR_PAIR> > | <VALUE_COMMA_LIST> "," <VALUE_OR_PAIR> > ; > > <VALUE_LIST> > : <VALUE_COMMA_LIST> > | <VALUE_LIST> S+ <VALUE_COMMA_LIST> > > <VALUE> > : NUMBER S* > | PERCENTAGE S* > | LENGTH S* > | EMS S* > | EXS S* > | ANGLE S* > | TIME S* > | STRING S* > | IDENT S* | URI S* | hexcolor | function > > <PROPERTY-DECL> > : <NAME> ':' <VALUE_LIST> ';' > | <NAME> ':' <VALUE_LIST> <IMPORTANT> ';' Counterexamples from CSS 2.1: font-family: Times New Roman, serif; ...this is (Times New Roman), (serif), not (Times) (New) (Roman, serif) font: bold italic 1em/1.2 Times New Roman, serif; ... this is (bold) (italic) (1em)/(1.2) ((Times New Roman), (serif)) I'd note that in CSS 2.1: The only properties using commas as separators are 'cursor', 'font-family', 'voice-family' and the 'font' shorthand (within the 'font-family' values). The only property using '/' to separate values is the 'font' shorthand. On the other hand, space-separated values are used in all shorthands and also in 'azimuth', 'background-position', 'border-spacing', 'content', 'counter-increment', 'counter-reset', 'font-family' (within single font names), 'play-during', 'text-decoration', and 'voice-family' (like 'font-family'). Thus there are three properties from which you can determine operator precedence: 'font-family', 'font', and 'voice-family'. 'font' is pretty much useless, however, since it uses space both above and below comma, and it uses '/' and (outer) space at equal precedence. So I don't think you can determine a clear operator precedence order from CSS 2.1, other than perhaps (based on 'font-family' and 'voice-family') that comma-separated things contain space-separated things (the opposite of what you describe, but I think quite logical). I think if anything it's the 'font' shorthand that's got the broken syntax, but that's been broken (internally contradictory precedence) since CSS1. I think it's also the one that's confusing for authors: it recently took me quite a while to spot the mistake in: font: 1em normal normal Arial, serif; (Note: most people don't have a font called 'normal normal Arial'.) I think the general rule that: a b, c d represents groups like this: (a b) (c d) rather than like this: a (b c) d makes sense, and we should stick to it, leaving 'font' as an exception. -David -- L. David Baron http://dbaron.org/ Mozilla Corporation http://www.mozilla.com/
Received on Sunday, 7 February 2010 07:43:43 UTC