Where is the HTML5 Document Type Definition?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 17:33:05
Jukka K. Korpela

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/nu/) 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.

Correct. There is no DTD. However, HTML5 documents should start with <!DOCTYPE html> So there's a DOCTYPE, but no DTD.

See:

I have created an HTML5 DTD for use in my PHP XML projects. It ain't beautiful, but it works with well-formed XHTML5 (that is, HTML5 expressed as XML).

You can grab it from my bitbucket account here:

https://bitbucket.org/kashbridge/dtd/overview

Enjoy!

imhotap

Certain Marcus from sgmljs.net created and analyzed an SGML DTD for HTML 5.1 and started a thread in the XML-DEV mailing list for review and discussion. The discussion revolves around entity definitions so far.

I've just completed my analysis of W3C's HTML 5.1 recommendation at http://sgmljs.net/docs/html5.html (from a markup language rather than web development PoV), and I'm publishing it here for review in the form of an initial SGML DTD for parsing HTML 5.1, along with a lengthy analysis text.

[…]

I'm aware that WHATWG and W3C have since long moved away from SGML (and XML in most web-related specification work), treating it as a legacy technique and with a somewhat presumptuous attitude in the specification text and elsewhere. But as the analysis of HTML5's grammar shows, they've essentially abandoned use of any formal methods alltogether (and it shows in at least two flaws discussed in the analysis).

Nothing official yet, but maybe this initiative will get traction, or at least find its users as an unofficial resource.

I think they did away with the old DTDs, now we just start HTML pages with: <!DOCTYPE HTML>

Maybe the W3C will come out with one eventually.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!