W3C home > Mailing lists > Public > www-style@w3.org > May 2012

RE: [css-background] Order of properties in background shorthand

From: Brian Manthos <brianman@microsoft.com>
Date: Thu, 31 May 2012 22:28:43 +0000
To: Joe Thomas <joethomas@motorola.com>, Tab Atkins Jr. <jackalmage@gmail.com>, "www-style@w3.org" <www-style@w3.org>
Message-ID: <4031779A10373C4AB7B9FBAD218A8BAC0824CA05@CH1PRD0310MB391.namprd03.prod.outlook.com>
Joe Thomas:
> IE6 parses only background-color correctly
> as it comes before newly introduced properties

I don't know all the IE (or industry) history here, but I disagree with your assessment here.

I think it was a mistake (either an implementation bug or a spec bug) for it not to reject the entire declaration back then.

I'm not suggesting we revise history but saying it "parses only background-color correctly" is wrong (IMO) in two ways.

Firstly, it's parsing "background" (the shorthand property) not the "background-color" property.  While that may sound minor it's important.  You're assuming that "background: red blue;" should be treated as "background: red;" but there's nothing that makes that necessarily the right choice.  The CSSWG could have chosen (and still could...) to make that a shorthand for a gradient, for example.

Secondly, and more importantly, when parsing "background" either the whole declaration should have been invalid (and have no rendering or OM impact) or none of it (and thus fully embraced by rendering and OM).  The fact that it "sort of accepted some of it, if you knew the right incantation order from the mages of old" is an unfortunate twist of history.

It's kind of like saying "I want a red sports car for $30k" and then being sold a blue toy car for $30k.  The contract of the entire declaration should be atomic, IMO.


> if we restrict the order of background shorthand properties generated by a CSS3 UA
For both specifications (2.1 and 3), the order of the parameters was intentionally flexible and had been this way a long time.  I find it highly unlikely this will change in my lifetime.


> So if we change the above order to "red url(dummy://test.png) 50% 50% / cover border-box"
As others have hinted, there isn't "an order" that the parser supports.  Or at least, nowhere near as rigid as you're describing.  I can see an opportunity for "convenience" in the canonical ordering being changed - but, as others have hinted - the notion of a canonical order (and which one) is also not settled in the WG.  So you're suggesting that something that "doesn't exist" be changed is... confusing.


> [if some other conditions were right] IE6 parses bg-color,
>bg-image and bg-position correctly and discards the rest.
As I noted in my prior reply, that's not an expected authoring pattern and - as I understand it - an explicit non-goal to evolve properties by adding new things ONLY to the end.  Again, the whole declaration should be ignored rather than "greedy gobbled" until "unrecognized parameters" are encountered.


Addressing your reply out of order a little...
> And assuming that the server feeds this generated result
> from CSS3 Browser to a CSS2.1 compatible browser like IE6.
I think this is the root problem.

If the server wants to support a CSS2.1 browser, it needs to output the CSS2.1 declaration prior to the CSS3 declaration.  When you see misbehavior of legacy browsers for such input then you may want to further adjust from there.


Hope this helps,
-Brian
Received on Thursday, 31 May 2012 22:31:12 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:54 GMT