简体   繁体   English

HTML 5 验证服务

[英]HTML 5 Validation Service

I am trying to check HTML 5 files for validity and have found the W3C validator .我正在尝试检查 HTML 5 文件的有效性,并找到了W3C 验证器 However I have found that this validator accepts grossly wrong HTML documents like this one:但是我发现这个验证器接受了严重错误的 HTML 文档,如下所示:

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>Hello World</title>
    Hello
</body>
</html>

Here I have removed the opening html tag, and the opening body tag and the validator reports:在这里,我删除了开头的 html 标记,以及开头的正文标记和验证器报告:

The document validates according to the specified schema(s).文档根据指定的模式进行验证。

I do not assume, that this document is anyhow compliant to the HTML 5 or any other HTML standard.我不认为本文档无论如何都符合 HTML 5 或任何其他 HTML 标准。 Obviously the validator is not very strict, when it comes to nesting of elements or opening/closing tags.显然,当涉及到元素的嵌套或打开/关闭标签时,验证器并不是很严格。

Is there a more strict validator out there, which reports every tiny deviation from standard HTML?是否有更严格的验证器,它报告与标准 HTML 的每一个微小偏差?

I do not assume, that this document is anyhow compliant to the html5 or any other html standard.我不认为本文档无论如何都符合 html5 或任何其他 html 标准。

But you are assuming that it isn't compliant.但是您假设它不合规。 You could check by reading the standard.你可以通过阅读标准来检查。

See, for example, the html element :例如,参见html 元素

Tag omission in text/html: text/html 中的标记省略:
An html element's start tag can be omitted if the first thing inside the html element is not a comment.如果 html 元素内的第一件事不是注释,则可以省略 html 元素的开始标记。
An html element's end tag can be omitted if the html element is not immediately followed by a comment.如果 html 元素后面没有紧跟注释,则可以省略 html 元素的结束标记。


Is there a more strict validator out there, which reports every tiny deviation from standard html?是否有更严格的验证器,它报告与标准 html 的每一个微小偏差?

While tool recommendations are off-topic for this site, there are no deviations from standard html in the code you've presented.虽然工具建议与此站点无关,但在您提供的代码中与标准 html 没有任何偏差。

The Nu validator is very good at what it does. Nu 验证器非常擅长它的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM