HTML5文档类型定义在哪里? [英] Where is the HTML5 Document Type Definition?

查看:161
本文介绍了HTML5文档类型定义在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

旧HTML / XHTML标准为它们定义了一个DTD(文档类型定义):

HTML 4.01 http://www.w3.org/TR/html401/sgml/dtd.html

XHTML 1.0 http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-严格的



这个DTD指定了嵌套元素的规则 - 哪些类型的元素可能出现在哪些类型的元素中。我在这里为XHTML 1.0制作了一个图表(对不起,我不再拥有该资源)



我想用新版本更新该图包括新的HTML5元素。但是,似乎没有HTML5 DTD。似乎嵌套规则是由HTML5中定义的各种内容模型定义的。

所以没有DTD,对吗?

后续问题 :HTML5中没有DTD的原因是什么? DTD是为所有不同类型的元素定义嵌套规则的好方法。为什么他们不包括这样的东西?



更新: 我发现这个:http://www.w3.org/TR/html5/dom.html#kinds-of-content

更新: Visual Studio团队为XHTML5制作了XML模式。我想这回答我的问题: http://blogs.msdn.com/b/webdevtools/archive/2009/11/18/html-5-intellisense-and-validation-schema-for -visual-studio-2008-and-visual-web-developer.aspx

解决方案

没有HTML5 DTD 。 HTML5 RC明确地在此表示讨论XHTML序列化,这显然也适用于HTML序列化。

HTML5的设计者认为DTD在表现力方面太有限,而HTML5验证器(基本上 http://validator.nu 的HTML5模式及其在 http://validator.w3.org )使用模式和临时检查,而不是基于DTD的验证。



而且,HTML5的设计使得为它写DTD是不可能的。例如,没有SGML方法来捕获HTML5规则,即任何以data-开头且符合某些常规规则的属性名称都是有效的。在SGML中,属性需要单独列出,因此DTD需要是无限的。



可以设计与HTML5相对应的DTD,但有一些遗漏,一些额外的规则强加,但他们不会真的是HTML5 DTD。我的实验的想法并不令人鼓舞:太多限制,太棘手了,而且DTD需要非常宽松,以至于很多语法错误都不会被捕获。

The "old" HTML/XHTML standards have a DTD (Document Type Definition) defined for them:

HTML 4.01 http://www.w3.org/TR/html401/sgml/dtd.html
XHTML 1.0 http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict

This DTDs specify the rules for nesting elements - "which types of elements may appear in which types of elements". I made a diagram for XHTML 1.0 here (sorry, I no longer have that resource)

I would like to update that diagram with a new version which also includes the new HTML5 elements. However, there doesn't seem to be a HTML5 DTD. It seems that the nesting rules are defined by the various content models that are defined in HTML5.

So there is no DTD, correct?

Follow-up question: Is there a reason why there is no DTD in HTML5? The DTD is such a nice method of defining the nesting rules for all the different types of elements. Why wouldn't they include such a thing?

Update: I found this: http://www.w3.org/TR/html5/dom.html#kinds-of-content I guess, this is the closest to having a DTD.

Update: The Visual Studio Team made a XML Schema for XHTML5. I guess that answers my question: http://blogs.msdn.com/b/webdevtools/archive/2009/11/18/html-5-intellisense-and-validation-schema-for-visual-studio-2008-and-visual-web-developer.aspx

解决方案

There is no HTML5 DTD. The HTML5 RC explicitly says this when discussing XHTML serialization, and this clearly applies to HTML serialization as well.

DTDs have been regarded by the designers of HTML5 as too limited in expressive power, and HTML5 validators (basically the HTML5 mode of http://validator.nu and its copy at http://validator.w3.org) use schemas and ad hoc checks, not DTD-based validation.

Moreover, HTML5 has been designed so that writing a DTD for it is impossible. For example, there is no SGML way to capture the HTML5 rule that any attribute name that starts with "data-" and complies with certain general rules is valid. In SGML, attributes need to be listed individually, so a DTD would need to be infinite.

It is possible to design DTDs that correspond to HTML5 with some omissions and perhaps with some extra rules imposed, but they won’t really be HTML5 DTDs. My experiment with the idea is not very encouraging: too many limitations, too tricky, and the DTD would need to be so permissive that many syntax errors would go uncaught.

这篇关于HTML5文档类型定义在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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