HTML头元素在w3.org验证器上没有正确注册?

时间:2015-08-31 14:53:43

标签: html css validation w3c-validation

我正在学习HTML,我的导师告诉我们使用w3.org html验证器来帮助检查代码。我正在使用一个简单的网页启动它显示正常但是当我把它放入验证器时,它会出错并且我完全被难倒了。

我的代码的开头是

<!DOCTYPE html>
<html>
<!-- Html is the element but tag is html + the open/close tags-->
<head>
<title> Around the World Music </title>
<img src="worldmusiclogo.jpg" alt="Around the World Music logo" title="Around the World Music Logo" >
<style>
h1 {
color: red;
}
h2 {
color: orange;
}
</style>
</head>

<body>
....rest of code

验证器输出

Info: The Content-Type was text/html. Using the HTML parser.

Info: Using the schema for HTML with SVG 1.1, MathML 3.0, RDFa 1.1, and ITS 2.0 support.

Error: Element style not allowed as child of element body in this context. (Suppressing further errors from this subtree.)

From line 12, column 1; to line 12, column 7

Logo" >↩↩↩<style>↩h1 {↩

Contexts in which element style may be used:
    If the scoped attribute is absent: where metadata content is expected.
    If the scoped attribute is absent: in a noscript element that is a child of a head element.
    If the scoped attribute is present: where flow content is expected, but before any other flow content other than inter-element whitespace and style elements, and not as the child of an element whose content model is transparent.
Content model for element body:
    Flow content.

Error: Stray end tag head.

From line 20, column 1; to line 20, column 7

↩</style>↩</head>↩↩<bod

Error: Start tag body seen but an element of the same type was already open.

From line 22, column 1; to line 22, column 6

↩</head>↩↩<body>↩<!--T

似乎问题是验证器将某些代码解释为<style>之前的头部结尾。因此,它认为样式位于错误的位置<body>,然后我的</head><body>标记是无关紧要的。谁能指出我做错了什么?

2 个答案:

答案 0 :(得分:3)

<img>不能是<head>的后代 - 删除该元素或将其移至<body>

答案 1 :(得分:0)

LUT['RefVal'] = LUT.groupby('ID').apply(lambda x: fun(x)) 中有img,如果您想设置图标,请尝试使用:

head
<link rel="icon" type="image/png" href="logo.png" />

中的