最低限度的HTML5 - 是否有效? [英] Bare minimum HTML5 - is it valid?

查看:133
本文介绍了最低限度的HTML5 - 是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读D3,其中一张幻灯片提到了最简单的HTML保罗爱尔兰的页面

I was reading up on D3, and one of the slides mentioned the most minimal HTML page by Paul Irish.

<!DOCTYPE html>
<meta charset="utf-8">
<body>
Hello, world!

我完全理解这个HTML的作用 - 但是,这个世界如何才能成为有效的HTML5,而且,它是否符合标准?或者这只是它的工作情况,但它会使规则

I understand exactly what this HTML does -- however, how in the world could this be valid HTML5, and further, is it standards compliant? Or is this just a case of it works, but it bends the rules?

推荐答案

< a href =http://www.w3.org/TR/html5 =nofollow> HTML5规范描述了文本/ html中的标签省略下可省略的标签。但是,规范说明

The HTML5 spec describes what tags can be omitted under Tag omission in text/html. However, the spec states:


非规范描述在text / html语法中是否为
开始和结束标记可以省略。此信息是多余的,
是可选标签部分中给出的规范要求,并且元素定义中提供的
仅为方便起见。

A non-normative description of whether, in the text/html syntax, the start and end tags can be omitted. This information is redundant with the normative requirements given in the optional tags section, and is provided in the element definitions only as a convenience.

由于它是非规范性的,我们不能依赖它来进行一致性检查。在规范的可选标签部分中,它列出了:

Since it's non-normative, we can not rely on it for conformance checking. In the normative optional tags section, it lists:


如果html元素中$ * $ b内的第一个内容不是注释,则可以省略html元素的开始标记。

An html element's start tag may be omitted if the first thing inside the html element is not a comment.

如果html元素不是
后面跟着注释,则可以省略html元素的结束标记。

An html element's end tag may be omitted if the html element is not immediately followed by a comment.

如果元素为空,则可以省略head元素的开始标记;如果head元素中的第一个元素是元素,则可以省略

A head element's start tag may be omitted if the element is empty, or if the first thing inside the head element is an element.

头元素的结束如果head元素不是
后面跟一个空格字符或注释,则可以省略tag。

A head element's end tag may be omitted if the head element is not immediately followed by a space character or a comment.

如果元素元素的开始标记可能被省略是空的,或
如果body元素中的第一个东西不是空格字符或
a注释,除非body元素中的第一个东西是
元,链接,脚本,样式或模板元素。

A body element's start tag may be omitted if the element is empty, or if the first thing inside the body element is not a space character or a comment, except if the first thing inside the body element is a meta, link, script, style, or template element.

如果body元素不是
,则会立即省略body元素的结束标记。

A body element's end tag may be omitted if the body element is not immediately followed by a comment.

因此,除了缺少 < title> ,这可能就是 w3验证者抱怨。还有迹象表明< title> 是必需的。首先,内容模型部分> < head> ,这是规范性的,声明:

So it seems the document is valid save for the missing <title>, which is probably why the w3 validator complains. There are further indications that <title> is required. First, the Content model section for <head>, which is normative, states:


如果文档是iframe srcdoc文档,或者标题信息
可从更高级别的协议获得:
元数据内容的零个或多个元素,其中不超过一个是title元素而不是
多个是基本元素。

If the document is an iframe srcdoc document or if title information is available from a higher-level protocol: Zero or more elements of metadata content, of which no more than one is a title element and no more than one is a base element.

否则:元数据内容的一个或多个元素,其中一个是
,一个是title元素,不超过一个是基本元素。

Otherwise: One or more elements of metadata content, of which exactly one is a title element and no more than one is a base element.

并且规范状态


必须包含哪些内容作为子元素的规范性描述
和元素的后代。

A normative description of what content must be included as children and descendants of the element.

这篇关于最低限度的HTML5 - 是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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