为什么不应该放在最顶端?

时间:2022-06-01 19:55:46

Please explain me what are the problems (if any), by putting the following declaration at the very top of the HTML page

请通过在HTML页面的最顶部放置以下声明来解释我有什么问题(如果有的话)

<?xml version="1.0" encoding="UTF-8"?>

3 个解决方案

#1


5  

Its not good because it will cause IE6 to go into quirks mode.

它不好,因为它会导致IE6进入怪癖模式。

http://www.456bereastreet.com/archive/200904/using_an_xml_declaration_triggers_quirks_mode_in_ie_6/

And if you've ever worked with IE6 in quirks mode you would know what a painful experience that is.

如果你曾经在怪癖模式下使用过IE6,你会知道这是多么痛苦的经历。

#2


1  

If used, it should be placed at the top. In fact, if it's needed, it pretty much must be placed at the top in order for the rest of the document to be read properly.

如果使用,它应该放在顶部。实际上,如果需要,它几乎必须放在​​顶部,以便正确读取文档的其余部分。

It's not needed if your document is UTF-8 or UTF-16. But if otherwise, you should use it. My opinion is you should use it anyway.

如果您的文档是UTF-8或UTF-16,则不需要它。但如果不是这样,你应该使用它。我的意见是你应该使用它。

The only reason not to use it would be for IE6 users, as IE6 will go into 'quirks mode' if you have that declaration.

不使用它的唯一原因是IE6用户,因为如果你有声明,IE6将进入'怪癖模式'。

But honestly... IE6 is a quirk mode anymore.

但老实说...... IE6已经是一种怪癖模式了。

Don't potentially mess up other more modern parsers for the benefit of an old one.

为了旧的解析器的利益,不要把其他更现代的解析器弄乱。

#3


0  

You can put it on the very top, but you should be aware of the consequences.

你可以把它放在最顶端,但你应该知道后果。

  • Some (older) browsers will try to download your page instead of display it
  • 某些(较旧的)浏览器会尝试下载您的页面而不是显示它

  • In some browsers, if your XHTML code has an error, it will not try to display it "best effort" like in HTML. Instead, you will get a cryptic XML error.
  • 在某些浏览器中,如果您的XHTML代码有错误,它将不会尝试像HTML中那样“尽力而为”。相反,您将收到一个神秘的XML错误。

Also, if you are using XML/XHTML, please make sure you send the right content-type header as well (e.g. application/xml instead of text/html).

此外,如果您使用XML / XHTML,请确保您也发送正确的内容类型标头(例如application / xml而不是text / html)。

#1


5  

Its not good because it will cause IE6 to go into quirks mode.

它不好,因为它会导致IE6进入怪癖模式。

http://www.456bereastreet.com/archive/200904/using_an_xml_declaration_triggers_quirks_mode_in_ie_6/

And if you've ever worked with IE6 in quirks mode you would know what a painful experience that is.

如果你曾经在怪癖模式下使用过IE6,你会知道这是多么痛苦的经历。

#2


1  

If used, it should be placed at the top. In fact, if it's needed, it pretty much must be placed at the top in order for the rest of the document to be read properly.

如果使用,它应该放在顶部。实际上,如果需要,它几乎必须放在​​顶部,以便正确读取文档的其余部分。

It's not needed if your document is UTF-8 or UTF-16. But if otherwise, you should use it. My opinion is you should use it anyway.

如果您的文档是UTF-8或UTF-16,则不需要它。但如果不是这样,你应该使用它。我的意见是你应该使用它。

The only reason not to use it would be for IE6 users, as IE6 will go into 'quirks mode' if you have that declaration.

不使用它的唯一原因是IE6用户,因为如果你有声明,IE6将进入'怪癖模式'。

But honestly... IE6 is a quirk mode anymore.

但老实说...... IE6已经是一种怪癖模式了。

Don't potentially mess up other more modern parsers for the benefit of an old one.

为了旧的解析器的利益,不要把其他更现代的解析器弄乱。

#3


0  

You can put it on the very top, but you should be aware of the consequences.

你可以把它放在最顶端,但你应该知道后果。

  • Some (older) browsers will try to download your page instead of display it
  • 某些(较旧的)浏览器会尝试下载您的页面而不是显示它

  • In some browsers, if your XHTML code has an error, it will not try to display it "best effort" like in HTML. Instead, you will get a cryptic XML error.
  • 在某些浏览器中,如果您的XHTML代码有错误,它将不会尝试像HTML中那样“尽力而为”。相反,您将收到一个神秘的XML错误。

Also, if you are using XML/XHTML, please make sure you send the right content-type header as well (e.g. application/xml instead of text/html).

此外,如果您使用XML / XHTML,请确保您也发送正确的内容类型标头(例如application / xml而不是text / html)。