4

我正在学习 HTML 5 并且有一个问题:可以在 XHTML 1.1 文档中使用 HTML 5 吗?如果是,那么有人可以举个例子吗?

4

2 回答 2

8

Do not confuse XHTML and HTML.

XHTML is HTML ruled to be a valid XML document. Actually the XHTML 1.1 standard does not apply to HTML 5 but to HTML 4.01.

What does it mean? You can pick a valid XHTML 1.1 document and it'll be a valid HTML 5 document but the counter-part is not always true. For example:

<button disabled></button>

It's valid HTML code (it doesn't matter which version) but it's not a valid XML statement (then it's not a valid XHTML document) because of the empty attribute. World is full of these examples (just Google), HTML is very relaxed about syntax (and HTML 5 didn't change this direction) and there are some other differences too (here, for an example). Moreover the HTML 5 standard introduced new tags that aren't part of XHTML 1.1 standard so a fully featured HTML 5 document (despite the syntax) won't be a valid XHTML 1.1 document.

References
Here a short list of good reference about this topic, selected from SO answers:

于 2012-05-24T07:53:37.273 回答
1

理论上不会,因为xhtml和html的标准集是不同的。但是,它是否工作完全取决于您使用的浏览器,大多数现代浏览器将显示另一组标签以及您定义的标准。

于 2012-05-24T07:58:30.507 回答