So here's what I understand (please correct if wrong) :
以下是我的理解(如有错误请纠正):
- HTML5 is the newest version (or at least soon to be released) of HTML and contains features that XHTML does not yet have
- HTML5是HTML的最新版本(或至少即将发布),包含XHTML还没有的特性
- XHTML served as MIME type text/html is equal to HTML for the purposes of rendering
- XHTML作为MIME类型的文本/html,在呈现的目的上等同于html。
- Converting from text/html to application/xhtml+xml is difficult because it's not HTML
- 从文本/html转换到应用程序/xhtml+xml是困难的,因为它不是html
- XML is not compatible with HTML
- XML与HTML不兼容
So my question is, what does XHTML have to do with HTML besides the usage of tags? What is the practical purpose of using XHTML over XML, or is there none?
所以我的问题是,除了标签的使用,XHTML和HTML有什么关系?在XML上使用XHTML的实际目的是什么?
4 个解决方案
#1
4
Yes, HTML5 will have features (nd even elements/tags) which XHTML does not yet have. It will also reintroduce some tags from HTML4 which were removed for XHTML. (iframe, is one of them, I think)
是的,HTML5将具有XHTML还没有的特性(甚至元素/标签)。它还将从HTML4中重新引入一些为XHTML删除的标记。(我想iframe就是其中之一)
If you want to know about the differences between HTML4/XHTML and HTML5, read the wikipedia entry on HTML 5: http://en.wikipedia.org/wiki/HTML_5#Differences_from_HTML_4.01.2FXHTML_1.x
如果您想了解HTML4/XHTML和HTML5之间的差异,请阅读HTML5上的wikipedia条目:http://en.wikipedia.org/wiki/HTML_5# difference es_from_html_4.01.2fxhtml_1.x
However, no, XHTML is not equal to HTML for the purposes of rendering. http://hixie.ch/advocacy/xhtml
但是,不,XHTML并不等同于HTML以呈现为目的。http://hixie.ch/advocacy/xhtml
XHTML is more XML than it is HTML. It essentially uses (most of) the elements ('tags') from HTML while respecting the stricter grammar and semantics of XML.
XHTML与其说是HTML,不如说是XML。它本质上使用(大部分)HTML中的元素(“标记”),同时尊重XML更严格的语法和语义。
It is not equal to HTML4 for the purposes of rendering. If you use a mime type of XHTML - since it is XML - you can end up with nasty parse errors if you do it wrong:
它不等于HTML4的渲染目的。如果您使用的是mime类型的XHTML(因为它是XML),那么如果您做错了,可能会导致严重的解析错误:
... but despite this problem using XHTML can result in more consistent behavior between browsers than HTML4; since HTML4 is not as strict, browsers try really hard to interpret ambiguous markup, and the browser's developers end up with some freedom to choose how these ambiguities are treated. This leads to inconsistencies, but with XHTML - being XML - the browser is supposed to refuse to render the page at all should it be ambiguous.
…但是,尽管使用XHTML的问题会导致浏览器之间的行为比HTML4更加一致;因为HTML4并没有那么严格,浏览器真的很难解释不明确的标记,浏览器的开发人员最终可以*地选择如何处理这些不明确的标记。这导致了不一致,但是由于XHTML是XML,如果页面不明确,浏览器应该拒绝呈现。
XHTML can lead to problems with older browsers though, especially with empty elements (self-closing tags) such as <br />
; an old browser won't know what to do with the /
and might think its part of the tag name and then you lose your line break.
但是,XHTML可能会导致老浏览器出现问题,尤其是在空元素(自闭标签)(例如
)的情况下;旧浏览器不知道如何处理/,可能会认为它是标记名的一部分,然后您就失去了换行符。
Lastly, I don't know what you mean by "Converting from text/html to application/xhtml+xml is difficult because it's not HTML" but I encourage you to check out the book "Refactoring HTML" by Elliotte Rusty Harold... it seems to be a 300+ page answer to the question ;)
最后,我不知道您所说的“从文本/html转换到应用程序/xhtml+xml是困难的,因为它不是html”是什么意思,但是我鼓励您阅读Elliotte Rusty Harold的《重构html》一书。这似乎是一个300多页的回答;
#2
1
HTML5 is the newest version (or at least soon to be released)
HTML5是最新版本(或至少即将发布)
Draft. Unstable. Subject to change. Not going to be released soon.
汇票。不稳定的。可能发生变化。不会很快被释放。
XHTML served as MIME type text/html is equal to HTML for the purposes of rendering
XHTML作为MIME类型的文本/html,在呈现的目的上等同于html。
More or less. Writing HTML compatible XHTML is more work than writing HTML or XHTML, and doesn't let you use any of the interesting bits of XHTML.
或多或少。编写与HTML兼容的XHTML比编写HTML或XHTML更有意义,并且不允许使用任何XHTML的有趣部分。
Converting from text/html to application/xhtml+xml is difficult because it's not HTML
从文本/html转换到应用程序/xhtml+xml是困难的,因为它不是html
Converting from HTML to XHTML is actually pretty trivial. Tidy can do it for lots of documents (including all valid HTML documents).
从HTML到XHTML的转换实际上非常简单。Tidy可以对很多文档(包括所有有效的HTML文档)进行处理。
XML is not compatible with HTML
XML与HTML不兼容
It would be truer to say that HTML isn't XML.
更真实的说法是HTML不是XML。
So my question is, what does XHTML have to do with HTML besides the usage of tags? What is the practical purpose of using XHTML over XML, or is there none?
所以我的问题是,除了标签的使用,XHTML和HTML有什么关系?在XML上使用XHTML的实际目的是什么?
The advantage of using XHTML over XML is roughly the same as using a car over a pile of metal and plastic. XML is a toolkit for building markup languages.
使用XHTML而不是XML的好处与在一堆金属和塑料上使用汽车差不多。XML是构建标记语言的工具包。
The advantage of using XHTML over HTML is that you can mix different markup languages into one document, so (for example) you could have an XHTML+SVG+MathML document. This requires the client to support all the languages involved (or for the unsupported ones to gracefully degrade).
与HTML相比,使用XHTML的好处是可以将不同的标记语言混合到一个文档中,因此(例如)可以有一个XHTML+SVG+MathML文档。这就要求客户端支持所涉及的所有语言(或不支持的语言,以优雅地降级)。
Unfortunately, this is impractical for most projects since Internet Explorer…
不幸的是,这对大多数项目来说是不切实际的,因为Internet Explorer…
doesn't support XHTML http://dorward.me.uk/tmp/xhtml/msiexhtml.png
不支持XHTML http://dorward.me.uk/tmp/xhtml/msiexhtml.png
#3
0
No, HTML5 will not have features that XHTML doesn't have, because it defines XHTML5 in the same document.
不,HTML5没有XHTML没有的特性,因为它在同一个文档中定义了XHTML5。
#4
0
From a programmers perspective: HTML had weaker (little or no) structural constraints by design, or at least web-browsers did not require these to produce some form of output. Each browser had its own logic for trying to piece together the missing structure.
从程序员的角度来看:HTML在设计上有较弱的(很少或没有)结构约束,或者至少web浏览器不需要这些约束来产生某种形式的输出。每个浏览器都有自己的逻辑来尝试拼凑缺失的结构。
XHTML enforced stricter structural constraints ... and is a subset of XML -- it is just stricter than HTML. The stricter semantics allows:
XHTML实施了更严格的结构约束…它是XML的子集——它比HTML更严格。更严格的语义允许:
- More consistent algorithms across browsers -- which means more consistency across browser implementations.
- 跨浏览器使用更一致的算法——这意味着跨浏览器实现更一致。
- Fewer clock-cycles per rendering -- which meant lower power devices could better handle rendering web-pages
- 每次渲染的时钟周期更少——这意味着功耗更低的设备可以更好地处理渲染web页面
- Stricter structural semantics are a requirement for the "semantic web" which means the structure can be leveraged to enable consistant extraction of usefull information from web-pages.
- 更严格的结构语义是“语义web”的需求,这意味着可以利用该结构从web页面中获取有用信息。
XHTML5 extends HTML to enable the web more interactive as far as I understand, and it is perhaps more significant than HTML to XHTML, as the stricter semantics should have been enforced from the get go. XHTML5 adds a lot of noticeable changes to the protocol.
据我所知,XHTML5扩展了HTML以使web具有更强的交互性,它可能比HTML对XHTML更重要,因为从一开始就应该执行更严格的语义。XHTML5为协议添加了许多值得注意的更改。
As far as XML vs HTML for the web -- well a browser needs some rudimentary fixed document structure to make some sense of the document, perhaps this isn't as significant as it used to be: by this I mean that XSLT and CSS can skin a document into presentable output for a web-browser. However a document should have some inherent document-esque fixed structuring that is meaningful for a browser without modern web techniques. HTML4 allows for a document to be structured so rudimentary browsers like lynx can display the document -- after all lynx does not stand a chance to render CSS and style elements like images.
至于XML和HTML web浏览器,需要一些基本的固定文档的文档结构,使某种意义上说,也许这并不是像过去那样重要的是:我的意思是,XSLT和CSS可以皮肤一个文档到像样的浏览器输出。然而,文档应该具有一些固有的文档式固定结构,对于没有现代web技术的浏览器来说是有意义的。HTML4允许一个文档的结构,像lynx这样的基本浏览器可以显示文档——毕竟lynx没有机会渲染CSS和样式元素,比如图像。
XHTML5 is in another league all together and probably excludes rudimentary browsers outright -- but its fixed tag vocabulary provide meaning for web-browsers, web-developers, and designers. web-browsers probably need certain tags to enable the new funky features -- but the vocabulary in itself is more elegant than just having to think of a web-page as a ad hoc XML document.
XHTML5是另一个联盟,可能完全排除了基本的浏览器——但是它固定的标签词汇为web浏览器、web开发人员和设计人员提供了意义。web浏览器可能需要特定的标签来启用新的功能,但是词汇本身要比把web页面想象成一个临时的XML文档更加优雅。
#1
4
Yes, HTML5 will have features (nd even elements/tags) which XHTML does not yet have. It will also reintroduce some tags from HTML4 which were removed for XHTML. (iframe, is one of them, I think)
是的,HTML5将具有XHTML还没有的特性(甚至元素/标签)。它还将从HTML4中重新引入一些为XHTML删除的标记。(我想iframe就是其中之一)
If you want to know about the differences between HTML4/XHTML and HTML5, read the wikipedia entry on HTML 5: http://en.wikipedia.org/wiki/HTML_5#Differences_from_HTML_4.01.2FXHTML_1.x
如果您想了解HTML4/XHTML和HTML5之间的差异,请阅读HTML5上的wikipedia条目:http://en.wikipedia.org/wiki/HTML_5# difference es_from_html_4.01.2fxhtml_1.x
However, no, XHTML is not equal to HTML for the purposes of rendering. http://hixie.ch/advocacy/xhtml
但是,不,XHTML并不等同于HTML以呈现为目的。http://hixie.ch/advocacy/xhtml
XHTML is more XML than it is HTML. It essentially uses (most of) the elements ('tags') from HTML while respecting the stricter grammar and semantics of XML.
XHTML与其说是HTML,不如说是XML。它本质上使用(大部分)HTML中的元素(“标记”),同时尊重XML更严格的语法和语义。
It is not equal to HTML4 for the purposes of rendering. If you use a mime type of XHTML - since it is XML - you can end up with nasty parse errors if you do it wrong:
它不等于HTML4的渲染目的。如果您使用的是mime类型的XHTML(因为它是XML),那么如果您做错了,可能会导致严重的解析错误:
... but despite this problem using XHTML can result in more consistent behavior between browsers than HTML4; since HTML4 is not as strict, browsers try really hard to interpret ambiguous markup, and the browser's developers end up with some freedom to choose how these ambiguities are treated. This leads to inconsistencies, but with XHTML - being XML - the browser is supposed to refuse to render the page at all should it be ambiguous.
…但是,尽管使用XHTML的问题会导致浏览器之间的行为比HTML4更加一致;因为HTML4并没有那么严格,浏览器真的很难解释不明确的标记,浏览器的开发人员最终可以*地选择如何处理这些不明确的标记。这导致了不一致,但是由于XHTML是XML,如果页面不明确,浏览器应该拒绝呈现。
XHTML can lead to problems with older browsers though, especially with empty elements (self-closing tags) such as <br />
; an old browser won't know what to do with the /
and might think its part of the tag name and then you lose your line break.
但是,XHTML可能会导致老浏览器出现问题,尤其是在空元素(自闭标签)(例如
)的情况下;旧浏览器不知道如何处理/,可能会认为它是标记名的一部分,然后您就失去了换行符。
Lastly, I don't know what you mean by "Converting from text/html to application/xhtml+xml is difficult because it's not HTML" but I encourage you to check out the book "Refactoring HTML" by Elliotte Rusty Harold... it seems to be a 300+ page answer to the question ;)
最后,我不知道您所说的“从文本/html转换到应用程序/xhtml+xml是困难的,因为它不是html”是什么意思,但是我鼓励您阅读Elliotte Rusty Harold的《重构html》一书。这似乎是一个300多页的回答;
#2
1
HTML5 is the newest version (or at least soon to be released)
HTML5是最新版本(或至少即将发布)
Draft. Unstable. Subject to change. Not going to be released soon.
汇票。不稳定的。可能发生变化。不会很快被释放。
XHTML served as MIME type text/html is equal to HTML for the purposes of rendering
XHTML作为MIME类型的文本/html,在呈现的目的上等同于html。
More or less. Writing HTML compatible XHTML is more work than writing HTML or XHTML, and doesn't let you use any of the interesting bits of XHTML.
或多或少。编写与HTML兼容的XHTML比编写HTML或XHTML更有意义,并且不允许使用任何XHTML的有趣部分。
Converting from text/html to application/xhtml+xml is difficult because it's not HTML
从文本/html转换到应用程序/xhtml+xml是困难的,因为它不是html
Converting from HTML to XHTML is actually pretty trivial. Tidy can do it for lots of documents (including all valid HTML documents).
从HTML到XHTML的转换实际上非常简单。Tidy可以对很多文档(包括所有有效的HTML文档)进行处理。
XML is not compatible with HTML
XML与HTML不兼容
It would be truer to say that HTML isn't XML.
更真实的说法是HTML不是XML。
So my question is, what does XHTML have to do with HTML besides the usage of tags? What is the practical purpose of using XHTML over XML, or is there none?
所以我的问题是,除了标签的使用,XHTML和HTML有什么关系?在XML上使用XHTML的实际目的是什么?
The advantage of using XHTML over XML is roughly the same as using a car over a pile of metal and plastic. XML is a toolkit for building markup languages.
使用XHTML而不是XML的好处与在一堆金属和塑料上使用汽车差不多。XML是构建标记语言的工具包。
The advantage of using XHTML over HTML is that you can mix different markup languages into one document, so (for example) you could have an XHTML+SVG+MathML document. This requires the client to support all the languages involved (or for the unsupported ones to gracefully degrade).
与HTML相比,使用XHTML的好处是可以将不同的标记语言混合到一个文档中,因此(例如)可以有一个XHTML+SVG+MathML文档。这就要求客户端支持所涉及的所有语言(或不支持的语言,以优雅地降级)。
Unfortunately, this is impractical for most projects since Internet Explorer…
不幸的是,这对大多数项目来说是不切实际的,因为Internet Explorer…
doesn't support XHTML http://dorward.me.uk/tmp/xhtml/msiexhtml.png
不支持XHTML http://dorward.me.uk/tmp/xhtml/msiexhtml.png
#3
0
No, HTML5 will not have features that XHTML doesn't have, because it defines XHTML5 in the same document.
不,HTML5没有XHTML没有的特性,因为它在同一个文档中定义了XHTML5。
#4
0
From a programmers perspective: HTML had weaker (little or no) structural constraints by design, or at least web-browsers did not require these to produce some form of output. Each browser had its own logic for trying to piece together the missing structure.
从程序员的角度来看:HTML在设计上有较弱的(很少或没有)结构约束,或者至少web浏览器不需要这些约束来产生某种形式的输出。每个浏览器都有自己的逻辑来尝试拼凑缺失的结构。
XHTML enforced stricter structural constraints ... and is a subset of XML -- it is just stricter than HTML. The stricter semantics allows:
XHTML实施了更严格的结构约束…它是XML的子集——它比HTML更严格。更严格的语义允许:
- More consistent algorithms across browsers -- which means more consistency across browser implementations.
- 跨浏览器使用更一致的算法——这意味着跨浏览器实现更一致。
- Fewer clock-cycles per rendering -- which meant lower power devices could better handle rendering web-pages
- 每次渲染的时钟周期更少——这意味着功耗更低的设备可以更好地处理渲染web页面
- Stricter structural semantics are a requirement for the "semantic web" which means the structure can be leveraged to enable consistant extraction of usefull information from web-pages.
- 更严格的结构语义是“语义web”的需求,这意味着可以利用该结构从web页面中获取有用信息。
XHTML5 extends HTML to enable the web more interactive as far as I understand, and it is perhaps more significant than HTML to XHTML, as the stricter semantics should have been enforced from the get go. XHTML5 adds a lot of noticeable changes to the protocol.
据我所知,XHTML5扩展了HTML以使web具有更强的交互性,它可能比HTML对XHTML更重要,因为从一开始就应该执行更严格的语义。XHTML5为协议添加了许多值得注意的更改。
As far as XML vs HTML for the web -- well a browser needs some rudimentary fixed document structure to make some sense of the document, perhaps this isn't as significant as it used to be: by this I mean that XSLT and CSS can skin a document into presentable output for a web-browser. However a document should have some inherent document-esque fixed structuring that is meaningful for a browser without modern web techniques. HTML4 allows for a document to be structured so rudimentary browsers like lynx can display the document -- after all lynx does not stand a chance to render CSS and style elements like images.
至于XML和HTML web浏览器,需要一些基本的固定文档的文档结构,使某种意义上说,也许这并不是像过去那样重要的是:我的意思是,XSLT和CSS可以皮肤一个文档到像样的浏览器输出。然而,文档应该具有一些固有的文档式固定结构,对于没有现代web技术的浏览器来说是有意义的。HTML4允许一个文档的结构,像lynx这样的基本浏览器可以显示文档——毕竟lynx没有机会渲染CSS和样式元素,比如图像。
XHTML5 is in another league all together and probably excludes rudimentary browsers outright -- but its fixed tag vocabulary provide meaning for web-browsers, web-developers, and designers. web-browsers probably need certain tags to enable the new funky features -- but the vocabulary in itself is more elegant than just having to think of a web-page as a ad hoc XML document.
XHTML5是另一个联盟,可能完全排除了基本的浏览器——但是它固定的标签词汇为web浏览器、web开发人员和设计人员提供了意义。web浏览器可能需要特定的标签来启用新的功能,但是词汇本身要比把web页面想象成一个临时的XML文档更加优雅。