XHTML 和 HTML 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4153403/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:12:48  来源:igfitidea点击:

What is difference between XHTML and HTML?

htmlxhtml

提问by Buhake Sindi

What is the exact difference between HTML and XHTML?

HTML 和 XHTML 之间的确切区别是什么?

I have seen related posts here, but I am not getting it exactly.

我在这里看到了相关的帖子,但我没有完全理解。

回答by Buhake Sindi

XHTML is not so much different from HTML 4.01 standard. The major differences are:

XHTML 与 HTML 4.01 标准没有太大区别。主要区别是:

  • XHTML elements must be properly nested.
  • XHTML elements must always be closed.
  • XHTML elements must be in lowercase.
  • XHTML documents must have one root element.
  • XHTML 元素必须正确嵌套
  • XHTML 元素必须始终关闭
  • XHTML 元素必须是小写的
  • XHTML 文档必须有一个根元素

Basically, XHTML is HTML (all the html tags are found in XHTML) that follows the rules of XML(because it is a family of XML).

基本上,XHTML 是遵循XML规则的 HTML(所有 html 标签都在 XHTML 中)(因为它是一个 XML 家族)。

More references can be found on:

可以在以下位置找到更多参考:

回答by Will Dean

XHTML is an application of XML, which is quite a strict angle-bracket language.

XHTML 是 XML 的应用,XML 是一种非常严格的尖括号语言。

HTML is an application of SGML, which is a much less strict angle-bracket language.

HTML 是 SGML 的应用,SGML 是一种不太严格的尖括号语言。

(XML is also an application of SGML.)

(XML 也是 SGML 的一种应用。)

At one time, people hoped that the solution to the mess of the late 90s web markup was to persuade everyone to write XHTML rather than HTML, perhaps in the hope that the enforced discipline would transform all those polo-necked frameless-spectacle wearing graphic designers into computer programmers. Alas, there was not actually much demonstrable benefit to all this exhausting prostration at the altar of the XHTML validator, so XHTML is now out of fashion and HTML is back in.

曾几何时,人们希望解决 90 年代后期 Web 标记混乱的方法是说服每个人编写 XHTML 而不是 HTML,也许是希望强制执行的纪律能改变所有那些戴着 polo 领无框眼镜的平面设计师成为计算机程序员。唉,在 XHTML 验证器的祭坛上进行的所有这些令人筋疲力尽的大礼拜实际上并没有多少明显的好处,所以 XHTML 现在已经过时了,而 HTML 又回来了。

回答by ppant

XHTML will be treated an application of XML only in case where MIME type application/xhtml+xml, application/xml, or text/xmlare used. An XHTML document served with a MIME type of text/html must be parsed and interpreted as HTML, so the HTML rules apply in this case.

只有在使用 MIME 类型application/xhtml+xmlapplication/xmltext/xml 的情况下,XHTML 才会被视为 XML 的应用程序。使用 MIME 类型的 text/html 提供的 XHTML 文档必须被解析和解释为 HTML,因此 HTML 规则适用于这种情况。

Check thislink for more on difference between XHTML and HTML

查看链接以了解有关 XHTML 和 HTML 之间差异的更多信息

回答by Norbert G Baranyikwa

  1. XHTML is case sensitive, different from HTML.
  2. XHTML's tags must be opened and closed different from HTML where a tag can be left as open.
  3. XHTML is not browser-dependent and can run on any browser platform, unlike HTML.
  1. XHTML 区分大小写,与 HTML 不同。
  2. XHTML 的标签必须打开和关闭,不同于 HTML 的标签可以保持打开状态。
  3. 与 HTML 不同,XHTML 不依赖于浏览器,可以在任何浏览器平台上运行。