我没有在你的HTML中看到doctype声明,所以我只能假设你的测试页面是以怪癖模式呈现的.
>
Why would it fallback to px? Is pixel always a preferred unit? Is there any rule defined in W3C working draft or recommendation?
它只会在怪癖模式下回落到px(而且我只相信某些属性).是的,px是首选的后备单位.这可以追溯到传统的HTML宽度和高度属性,它们将像素长度视为无单位数.
>
Is there a rule which makes it mandatory for a UA to fallback to a preferred unit?
不,因此您观察到的行为不一致.但是,在标准模式下,UA需要忽略没有单位的长度值;该单元不是可选的,如您引用的Microsoft Connect中所述.
In CSS2.1,所有非零长度值必须具有单位.
>
Given the above example,which of the following is a correct behavior:
Internet Explorer: In Quirks mode (IE6,4..) width and border-width used to fallback to px. Since IE7 (till present,IE10RP) it ignores the whole rule if unit is missing. Therefore both rules were ignored.
Firefox 13: In the above example width fallback to px,but border-width was ignored.
Chrome 19,Safari 5.1.2: Both width and border-width fallback to px.
同样,基于您的页面处于怪癖模式的假设,我只能说虽然规范提到了古怪的行为,但是这些古怪行为的具体细节没有在规范中定义(对于明显的和不是 – 如此明显的原因).
我猜测Microsoft改变了IE7中的怪癖模式行为以反映无单位值的标准行为,因为所有浏览器中都存在怪癖模式(IE< 6除外)并且由相同的不正确doctype或缺少doctype触发.据我所知,标准模式下的行为并没有改变.