[英]W3C markup validation errors
I tried W3C Markup validation with a simple HTML page. 我尝试使用简单的HTML页面进行W3C标记验证 。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Title</title>
<script src="script/myScript.js" type="text/javascript"></script>
<link href="style/theme.css" rel="stylesheet"></link>
<!--[if lte IE 8]>
<link href="style/themeIE8.css" rel="stylesheet"></link>
<![endif]-->
<noscript>Please enable JavaScript in your browser to view this page properly, to view the basic page of the site click the link <a href="no-javascipt/main.aspx">main.aspx</a>
</noscript>
</head>
<body class="layout">
<div class="header"></div>
<div class="content"></div>
<div class="footer"></div>
</body>
</html>
and got the following errors 并出现以下错误
I guess in the noscript
tag (or generally in the head tag itself) using DOM elements like a
is not okay, Is there any alternative to that? 我猜在
noscript
标记(或通常在head标记本身)中使用DOM元素(例如a
是不行的,还有其他替代方法吗? ie if script is not found provide a link to a page that doesn't need script 即,如果找不到脚本,请提供指向不需要脚本的页面的链接
and any idea as to why I am getting the errors for link
& body
tags? 以及关于为什么我会收到
link
和body
标签错误的任何想法? Thanks 谢谢
link
tag doesn't have a close tag, . </link>
link
标记没有结束标记 。 As such, it's invalid. </link>
因此,它是无效的。 If you want to close it inline, do it like this:
如果要内联关闭,请按以下步骤操作:
<link ... />
Also, you need to shift your <noscript>
tag inside the body
tag and between the head
tag as it contains text content. 另外,您还需要在
body
标签内部和head
标签之间移动<noscript>
标签,因为它包含文本内容。
Though, using something like this is valid if you place in the head
tag 1 . 但是,如果将这样的东西放在
head
标签1中,则是有效的。
<noscript><link href="style/theme.css" rel="stylesheet" /></noscript>
1. In a head element, if scripting is disabled for the
noscript
element1. 在head元素中,如果
noscript
元素的脚本禁用
Thenoscript
element must contain onlylink
,style
, andmeta
elements.noscript
元素必须仅包含link
,style
和meta
元素。In a head element, if scripting is enabled for the
noscript
element在head元素中,如果为
noscript
元素启用了noscript
Thenoscript
element must contain only text, except that invoking the HTML fragment parsing algorithm with the noscript element as the context element and the text contents as the input must result in a list of nodes that consists only oflink
,style
, andmeta
elements that would be conforming if they were children of thenoscript
element, and no parse errors.noscript
元素只能包含文本,除了调用HTML片段解析算法时,以noscript元素为上下文元素,以文本内容为输入,必须生成仅由link
,style
和meta
元素组成的节点列表如果它们是noscript
元素的子元素,并且没有解析错误,则将是符合条件的。
Correct Markup 正确的标记
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Title</title>
<script src="script/myScript.js" type="text/javascript"></script>
<link href="style/theme.css" rel="stylesheet" />
<!--[if lte IE 8]>
<link href="style/themeIE8.css" rel="stylesheet" />
<![endif]-->
</head>
<body class="layout">
<noscript>Please enable JavaScript in your browser to view this page properly, to view the basic page of the site click the link <a href="no-javascript/main.aspx">main.aspx</a>
</noscript>
<div class="header"></div>
<div class="content"></div>
<div class="footer"></div>
</body>
</html>
Check you style link which is not right. 检查您的样式链接不正确。 Style link should be self close.
样式链接应该是自关闭的。 ie
即
<link href=".." rel="stylesheet" />
and because there is written text not linked style or script so it should be under body tag. 并且因为有书面文字没有链接的样式或脚本,所以它应该在body标签下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.