XHTML,HTML和XML之间的实际区别 [英] Practical Difference between XHTML, HTML, AND XML

查看:222
本文介绍了XHTML,HTML和XML之间的实际区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,这是我的理解(如果错了,请更正):




  • HTML5是最新的版本)的HTML并包含XHTML尚未具有的功能

  • XHTML作为MIME类型text / html等于HTML以便呈现

  • 从text / html转换为application / xhtml + xml很难,因为它不是HTML

  • XML与HTML不兼容



所以我的问题是,除了使用标签之外,XHTML与HTML有什么关系?

解决方案

是的,HTML5将具有特性元素/标签),XHTML还没有。它还将从HTML4重新引入一些标签,这些标签已针对XHTML删除。 (iframe,是其中之一,我想)



如果你想知道HTML4 / XHTML和HTML5之间的区别,请阅读HTML 5上的wikipedia条目: a href =http://en.wikipedia.org/wiki/HTML_5#Differences_from_HTML_4.01.2FXHTML_1.x =nofollow noreferrer> http://en.wikipedia.org/wiki/HTML_5#Differences_from_HTML_4.01.2FXHTML_1 .x



但是,没有,为了呈现的目的,XHTML不等于HTML。 ...它似乎是一个300多页的答案的问题;)


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
  • XHTML served as MIME type text/html is equal to HTML for the purposes of rendering
  • Converting from text/html to application/xhtml+xml is difficult because it's not HTML
  • XML is not compatible with 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?

解决方案

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)

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

However, no, XHTML is not equal to HTML for the purposes of rendering. 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.

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:

... 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 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.

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 ;)

这篇关于XHTML,HTML和XML之间的实际区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆