验证器中的杂散开始标记 HTML?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16123945/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:42:08  来源:igfitidea点击:

Stray start tag HTML in validator?

htmlvalidation

提问by Bonnie

I am trying to validate this HTML document in http://validator.w3.org/#validate_by_inputbut I am getting the following errors:

我正在尝试在http://validator.w3.org/#validate_by_input 中验证此 HTML 文档,但出现以下错误:

Line 3, Column 47: Stray start tag html.

第 3 行,第 47 列:杂散开始标记 html。

<!--[if IE 7]><!--><html lang="en" class="ie7"><!--<![endif]-->

Line 4, Column 47: Stray start tag html.

第 4 行,第 47 列:杂散开始标记 html。

<!--[if IE 8]><!--><html lang="en" class="ie8"><!--<![endif]-->

Line 5, Column 47: Stray start tag html.

第 5 行,第 47 列:杂散开始标记 html。

<!--[if IE 9]><!--><html lang="en" class="ie9"><!--<![endif]-->

Line 6, Column 46: Stray start tag html.

第 6 行,第 46 列:杂散开始标记 html。

<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->

This is the HTML I am inputting:

这是我输入的 HTML:

<!DOCTYPE html>
<html lang="en-US">
<!--[if IE 7]><!--><html lang="en" class="ie7"><!--<![endif]-->
<!--[if IE 8]><!--><html lang="en" class="ie8"><!--<![endif]-->
<!--[if IE 9]><!--><html lang="en" class="ie9"><!--<![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
<head>
<title>Test</title>
</head>
<body>
</body>
</html>

Any ideas where I'm going wrong?

任何想法我哪里出错了?

采纳答案by Ozerich

Correct conditional comments:

正确的条件注释:

<!--[if IE 7]><html lang="en" class="ie7"><![endif]-->
<!--[if IE 8]><html lang="en" class="ie8"><![endif]-->
<!--[if IE 9]><html lang="en" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><html lang="en"><![endif]-->
<!--[if !IE]><html lang="en-US"><![endif]-->

回答by Rob

You don't close them. That's all and you define 2 html tags now.

你不关闭它们。这就是全部,您现在定义 2 个 html 标签。

回答by Jensd

You start with a html-tag that's always present and then you add html-tags depending on version of IE so you might very well end up with multiple html-tags.

您从始终存在的 html 标签开始,然后根据 IE 的版本添加 html 标签,因此您很可能最终会得到多个 html 标签。

回答by user5104334

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->

Use this file and then start tag...

使用此文件,然后开始标记...