HTML5是否有效的XML? [英] Is HTML5 valid XML?
问题描述
/> gt;
结尾的标签,例如< br />
仍然可以在HTML5中使用。我认为只有< br>
-style可以使用。所有在互联网上的谈话都是关于使用后者的。 有人可以向我解释这个吗?这看起来很混乱,并且记录不完全。
这引出了另一个问题:HTML 5是否被认为是格式良好的XML?
没有。反例: 以下是有效的HTML5,但是无效的XHTML5: 可以省略一些结束标记: 没有值的属性(布尔属性): 请参阅:更正已禁用属性的值 不带引号的属性,例如: 隐式开放元素和多个顶级元素。 一些HTML元素是隐式创建的。例如。
< p>首先
< p>第二个
脚本逃脱魔术:
<脚本>< a取代;< /脚本>
< input type =textdisabled />
< div data-a = b>< / div>
HTML
。这允许HTML具有多个顶级元素:
<!doctype html>< title> a<标题>< p>一种与LT; / p为H.
有效的XHTML无效HTML:
-
-
ENTITY
以及其他感叹号标记结构中的CDATA ,这让人笑了:亿笑笑XML DoS攻击工作?
有效的HTML和XHTML,但含义不同:
- HTML有数百个命名字符引用(例如
& pound;
,& copy;
) ,XML只有5个(quot
,amp
,lt
,gt
)。
I am confused. A co-worker turned me on to the possibility that tags ending in />
, such as <br />
can still be used in HTML5. I thought that only <br>
-style could be used. All of the "talk" across the Internet is about using the latter.
Could someone please explain this to me? This seems very confusing and poorly documented.
And this brings up another question: Is HTML 5 considered to be well-formed XML?
No. Counter-examples:
These are valid HTML5 but invalid XHTML5:
Some closing tags can be omitted:
<p>First <p>Second
script
escape magic:<script><a></script>
Attributes without values (boolean attributes):
<input type="text" disabled />
Attributes without quotes, e.g.:
<div data-a=b></div>
See: In XHTML 1.0 Strict do attribute values need to be surrounded with quotes?
Implicit open elements and multiple top level elements.
Some HTML elements are created implicitly. E.g.
html
. This allows the HTML to have "multiple top level elements":<!doctype html><title>a</title><p>a</p>
Valid XHTML that is invalid HTML:
CDATA
constructs with invalid tags insideENTITY
and other exclamation mark constructs, which allow for billion laughs: How does the billion laughs XML DoS attack work?
Valid HTML and XHTML but with different meanings:
- HTML has hundreds of named character references (e.g.
£
,©
), XML has only 5 (quot
,amp
,apos
,lt
,gt
).
这篇关于HTML5是否有效的XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!