且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

HTML5向后兼容XHTML吗?

更新时间:2023-02-17 14:43:07

首先,IE确实渲染了内联网默认情况下,站点处于兼容模式但是,这是一个配置设置,可以关闭:如果可能的话,我建议您的第一个解决方案就是在网络上的所有计算机上关闭此设置。 (这是否是一个可行的解决方案将取决于您的网络规模,您的组策略,以及其他内部网站点将受到影响)

First up, IE does indeed render intranet sites in compatibility mode by default. However, it is a config setting and can be switched off: if possible, I'd suggest that your first solution would simply be to switch off this setting on all the machines on your network. (whether this is a viable solution will depend on the size of your network, your group policies, and what other intranet sites would be affected)

现在回答您的问题。

可以在要以标准模式呈现的任何网站上指定HTML5文档类型。如果您已经在使用XHTML,那么对您来说唯一的影响就是浏览器将不再严格执行严格的XHTML合规性。您完全有权继续使用XHTML代码,但不会强制执行。

The HTML5 doctype can be specified on any site that you want to render in standards mode. If you're already using XHTML, the only effect for you will be that the browser will no longer rigidly enforce strict XHTML compliance. You are perfectly entitled to continue using XHTML code, but it won't be enforced.

HTML5 doctype是专门选择的,因为它适用于现有的浏览器,包括旧版本的IE浏览器。你应该可以将它放到任何页面上,它应该可以正常工作。

The HTML5 doctype was specifically chosen because it works with existing browsers, including older versions of IE. You should be able to put it onto any page, and it should just work.

它不会对IE进入兼容模式有任何影响。任何其他文件类型也不会。您提到的 X-UA兼容解决方案是解决方案(除非您可以设置我之前提到的配置设置),并且与doctype无关 - 您即使您使用HTML5文档类型,它仍然需要它。

What it won't do is have any effect at all on IE going into compatibility mode. Nor will any other doctype. The X-UA-Compatible solution you mentioned is the solution to this (unless you can set the config setting I mentioned earlier), and is un-related to the doctype - you'll still need it even if you use the HTML5 doctype.