Firefox拒绝样式元素,如果CSS选择器包含地址元素 [英] Firefox refusing to style element if CSS selector contains address element

查看:114
本文介绍了Firefox拒绝样式元素,如果CSS选择器包含地址元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在CSS选择器中使用< address> 元素,Firefox似乎拒绝为html元素设定样式。

Firefox appears to be refusing to style an html element if i use the <address> element in the CSS selector.

示例:

<footer>
    <address>
        <ul>
            <li id="email_address">email@website.com</li>
            <li id="phone_number">(555) 555 - 5555</li>
        </ul>
    </address>
</footer>



address li { color: #0000ff; } /* fails */
#phone_number { color: #ff0000; } /* works as expected */

我在FF 3.6.12看到这个,预期在Safari 5.0.3中

I'm seeing this on FF 3.6.12, works as expected in Safari 5.0.3

有什么想法为什么会发生这种情况?

Any idea why this is happening?

推荐答案

其原因其实很简单。 Firefox 3.6尚未符合HTML5草稿规格。使用Firebug检查< address> 元素,我们可以看到Firefox 看到的内容:

The reason for this is actually quite simple. Firefox 3.6 does not conform to the HTML5 draft specifications yet. Inspecting the <address> element with Firebug, we can see what Firefox sees:

<footer>
    <address>
        </address><ul>
            <li id="email_address">email@website.com</li>
            <li id="phone_number">(555) 555 - 5555</li>
        </ul>
</footer>

正如你所看到的,Firefox如何解释你的HTML,如上所示。 < address> 元素现在为空,因此< li> 元素未设置样式。

As you can see, Firefox has somehow interpreted your HTML as shown above. The <address> element is now empty, and thus the <li> elements are not styled.

但是为什么?通过 HTML4规范,我们可以看到< address> 元素内联元素(如 Alohci 的意见)应该只包含内联元素。

But why? Looking through the HTML4 specifications, we can see that the <address> element is an inline element (as stated by Alohci in the comments) should only contain inline elements.

<!ELEMENT ADDRESS - - (%inline;)* -- information on author -->
<!ATTLIST ADDRESS
  %attrs;                              -- %coreattrs, %i18n, %events --
  >

由于Firefox 3.6不符合HTML5规格,至少至Firefox,是不是有效的,浏览器处理未指定行为的方式是它们断开,如上所示。

Since Firefox 3.6 does not conform to the HTML5 specifications, to Firefox at least, the HTML you used above is not valid, and the way browsers deal with unspecified behavior is that they break, as shown above.

没有办法解决这个问题 - HTML5只是在草拟阶段,浏览器不需要通过任何方式符合他们。您可能需要向Mozilla的 Bugzilla错误跟踪系统提交错误报告。

There's no way to fix this - HTML5 is only in the drafting stages, and browsers are not required to conform to them by any means. You may wish to submit a bug report to Mozilla's Bugzilla bug tracking system.

这篇关于Firefox拒绝样式元素,如果CSS选择器包含地址元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆