IE6 和 XML 序言
使用像 XML prolog 这样的 XML prolog
? xml version="1.0" encoding="iso-8859-1"? >
和像 Doctype 这样的 Doctype,
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
我可以让我的页面按预期呈现。 然而,在 IE7 中,同一页面无法正确呈现。 (div 内的跨度不垂直对齐)网络上的文章表明 XML prolog + doctype 将使 IE6 陷入怪异模式。 然而这篇文章似乎另有建议,尽管它没有提及它适用的版本(是 6 还是 7),尽管这篇文章的日期是 2005 年 9 月,这让我相信它适用于 IE6
XML Prolog + doc 类型是否会使 IE6 进入怪异模式? IE7呢? 对于支持或反对使用 prolog + doctype 有什么建议吗?
With an XML prolog like
? xml version="1.0" encoding="iso-8859-1"? >
and a Doctype like
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
I can get my page to render as expected. However, in IE7 the same page does not render correctly. (a span inside a div does not align vertically) Articles on the web suggest that XML prolog + doctype will throw IE6 into quirks mode. However this article seems to suggest otherwise, although it does not mention the version (is it 6 or 7) it applies to, though the article is dated sep 2005 which makes me believe it applies to IE6
Does XML Prolog + doc type throw IE6 into quirks mode? What about IE7? Any recommendations on for or against using the prolog + doctype?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在文档类型之前添加 XML 序言将使 IE6 进入怪异呈现模式。 (参见此处。)事实上,文档类型之前的任何空格都会使 IE6 陷入怪癖模式。 IE7及以上版本则不然。 您可以使用
document.compatMode
(示例)让浏览器告诉您它正在使用什么模式进行渲染。MSDN 上的 IE 博客条目提到了对 IE7 所做的更改,这些更改允许 IE7 在使用适当的文档类型时保持标准模式,即使它前面有 XML 序言。
我通常建议省略序言并将浏览器保持在标准模式; 我认为这将使您的生活更加轻松。
Adding an XML prolog before the doctype will throw IE6 into quirks rendering mode. (See here.) In fact, any space before the doctype will throw IE6 into quirks mode. This is not the case for IE7 and above. You can use
document.compatMode
(example) to have the browser tell you what mode it is using to do the rendering.The IE blog entry on MSDN is referring to changes made to IE7 that allow IE7 to stay in standards mode when using the appropriate doctype even if it is preceded by an XML prolog.
I would generally recommend omitting the prolog and keeping the browser in standards mode; I think this will make your life easier moving forward.