- From: fantasai <fantasai.lists@inkedblade.net>
- Date: Mon, 19 Dec 2011 22:54:18 -0500
- To: www-style@w3.org
On 05/27/2011 09:12 PM, Tab Atkins Jr. wrote: > I and some other webdevs were talking about background-position > yesterday, and were struck by how confusing the grammar for it is. > For ease of reference, I reproduce it here: > > <bg-position> = [ > [ top | bottom ] > | > [<percentage> |<length> | left | center | right ] > [<percentage> |<length> | top | center | bottom ]? > | > [ center | [ left | right ] [<percentage> |<length> ]? ]&& > [ center | [ top | bottom ] [<percentage> |<length> ]? ] > ] > > While the grammar is technically correct, it suggests several > incorrect interpretations due to its structure. [...] > > I suggest restating the grammar so that each class of forms is more > clearly encapsulated in each clause, even if it does admit multiple > ways to produce a given value. That is, something like this: > > <bg-position> = [ > [<percentage> |<length> | left | center | right ] || > [<percentage> |<length> | top | center | bottom ] > | > [ center | [[ left | right ] [<percentage> |<length> ]?] ]&& > [ center | [[ top | bottom ] [<percentage> |<length> ]?] ] > ] > > Here, I have collapsed the 1-value clause into the two-value clause by > using ||. By switching to this operator rather than concatenation, > I've also made it cover the fact that you can put vertical keywords > before horizontal keywords. In the 3/4-value clause, I've added an > additional set of brackets to make the binding explicit. Unfortunately, your grammar is technically incorrect. If you are using the two-value form with either <percentage> or <length>, it must be in horizontal-then-vertical order. Your grammar admits '50% left', which is invalid per CSS2.1. I'm not against changing the grammar to be more understandable, but I won't change it to be less correct. Filed as ISSUE-212 https://www.w3.org/Style/CSS/Tracker/issues/212 ~fantasai
Received on Tuesday, 20 December 2011 03:54:54 UTC