简体   繁体   English

XHTML是HTML的一个子集吗?

[英]Is XHTML a subset of HTML?

What I know is (please correct me if I am wrong): 我所知道的是(如果我错了,请纠正我):

  • XML is a subset of SGML. XML是SGML的子集。
  • XHTML is an application and a subset of XML. XHTML是一个应用程序和XML的子集。
  • HTML is an application of SGML. HTML是SGML的一个应用程序。

Does this imply that XHTML is a subset of HTML or does this statement hold for any other reason? 这是否意味着XHTML是HTML的一个子集,或者由于任何其他原因而保留此语句?

XML is not a subset of SGML but comes close. XML不是SGML的子集,但却很接近。 XML has its own rules that partly differ from SGML, though mostly it consists of SGML with most of its features omitted. XML有自己的规则,部分与SGML不同,但大部分都由SGML组成,其中大部分功能都被省略了。

XHTML (which is a collective name for several markup languages) can be called an application and a subset of XML, but in addition to that, XHTML tags have meanings assigned to them, whereas XML as such does not say anything about meaning. XHTML(它是几种标记语言的统称)可以称为应用程序和XML的子集,但除此之外,XHTML标记具有分配给它们的含义,而XML本身并没有提及任何有关含义的内容。

HTML is nominally an application of SGML in the HTML 2.0, HTML 3.2, HTML 4.0, and HTML 4.01 specifications, but this was always just theory. HTML名义上是SGML在HTML 2.0,HTML 3.2,HTML 4.0和HTML 4.01规范中的应用,但这始终只是理论。 Only validators treat HTML as SGML. 只有验证器将HTML视为SGML。 There was never any browser that implemented HTML as defined in those specifications; 从来没有任何浏览器实现这些规范中定义的HTML; several SGML features, which are in princple part of them, lack all support. 一些SGML功能,它们是其中的一部分,缺乏所有支持。

Even if the subset relations were all true, the conclusion “XHTML is a subset of HTML” would not follow from the premises. 即使子集关系都是正确的,结论“XHTML是HTML的一个子集”也不会遵循该前提。 A ⊂ B and C ⊂ B and D ⊂ B do not imply C ⊂ D. A⊂B和C⊂B和D⊂B并不意味着C⊂D。

XHTML is not a subset of HTML. XHTML不是HTML的子集。 There are XHTML specifications that contain elements not included in HTML specifications. XHTML规范包含HTML规范中未包含的元素。 And both XHTML and HTML are collective nouns. XHTML和HTML都是集体名词。 XHTML 1.0 has been characterized as being HTML 4.01 in XML syntax, so they might be called alternative syntactic forms. XHTML 1.0已经被描述为XML语法中的HTML 4.01,因此它们可能被称为替代语法形式。 But even this isn't strictly true; 但即便如此,这并非严格意义上的; there are several poorly documented discrepancies between XHTML 1.0 and HTML 4.01, in addition to the obvious syntactic differences. 除了明显的语法差异之外,XHTML 1.0和HTML 4.01之间存在一些记录不良的差异。 HTML5 is being defined with two syntaxes, two serializations, “HTML” and “XHTML”, but even here, there are inevitable differences in addition to different serialization. HTML5定义有两种语法,两种序列化,“HTML”和“XHTML”,但即使在这里,除了不同的序列化之外,还存在不可避免的差异。

Does this imply that XHTML is a subset of HTML 这是否意味着XHTML是HTML的子集

No it doesn't. 不,不。

Is XHTML a subset of HTML? XHTML是HTML的一个子集吗?

No. And neither is HTML a subset of XHTML. 不,HTML也不是XHTML的子集。

For example: 例如:

  • <input name="surname"> is valid HTML but not valid XHTML. <input name="surname">是有效的HTML但不是有效的XHTML。
  • <div /> is valid XHTML but not valid HTML. <div />是有效的XHTML,但不是有效的HTML。

Traditionally, HTML and XHTML were specified separately. 传统上,HTML和XHTML是分开指定的。 HTML5 defines both syntaxes in a single specification. HTML5在单个规范中定义了两种语法。 But the two syntaxes are mutually exclusive. 但这两种语法是互斥的。 However, it is possible to use mark-up in your documents in such a way that will comply with both syntaxes. 但是,可以在文档中使用符合两种语法的标记。 eg by using <input name="surname" /> and <div></div> 例如,使用<input name="surname" /><div></div>

You asked two questions: 你问了两个问题:

(a) is XHTML a subset of HTML? (一)XHTML是HTML的一个子集吗? Answer, no. 答案,不。 Easily proved by showing that XHTML allows things (such as an XML declaration) which HTML does not allow. 通过展示XHTML允许HTML不允许的内容(例如XML声明)轻松证明。

(b) if H is a subset of S and X is a subset of S, does this imply X is a subset of H? (b)如果H是S的子集而X是S的子集,这是否意味着X是H的子集? Most definitely not: that would be a gross logical error. 绝对不是:这将是一个严重的逻辑错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM