Html HTML5 验证错误:看到正文开始标记,但已打开相同类型的元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9283409/
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
HTML5 Validation Error: body start tag seen but an element of the same type was already open
提问by Chris Reedy
I was hoping that someone may know how to resolve this HTML5 validation error. When I try to validate my page: http://blog.genesispetaluma.comusing http://validator.w3.org, it gives me the following error code:
我希望有人知道如何解决这个 HTML5 验证错误。当我尝试使用http://validator.w3.org验证我的页面:http: //blog.genesispetaluma.com 时,它给了我以下错误代码:
Error Line 90, Column 63: An body start tag seen but an element of the same type was already open.
错误第 90 行,第 63 列:看到正文开始标记,但已打开相同类型的元素。
<body class="home blog single-author two-column right-sidebar">
I interpreted this error to mean that I have two body tags in the code. However, I have searched everywhere and can only find one <body>
(the one referenced by the error) and one </body>
. Can anyone please tell me how to resolve this error?
我将此错误解释为代码中有两个 body 标签。但是,我到处搜索,只能找到一个<body>
(错误引用的那个)和一个</body>
. 谁能告诉我如何解决这个错误?
采纳答案by Emil H
Possibly it's because:
可能是因为:
<div id="wrapFix">
<div id="drawLogo1">
<div id="drawLogo2">
<img src="http://genesispetaluma.com/img/logoNew.png" alt="Genesis Fitness G stylelogo">
</div>
</div> <!-- end of drawLogo1 -->
Is between your closing head tag and opening body tag. I.e. lines 81-87
位于结束头标签和开始身体标签之间。即第 81-87 行
回答by TheCarver
I had a similar problem but with <head>
, giving the following W3C markup error:
我有一个类似的问题,但是<head>
,给出了以下 W3C 标记错误:
A head start tag seen but an element of the same type was already open
看到了一个开头标签,但相同类型的元素已经打开
I had this code:
我有这个代码:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head>
When it was supposed to be:
当它应该是:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
I knew that was wrong but it's hard to spot sometimes, as you're just so used to the header code being correct 99% of the time. I obviously cut n pasted some code and that ended up in the wrong place.
我知道这是错误的,但有时很难发现,因为您已经习惯了 99% 的标题代码都是正确的。我显然剪切 n 粘贴了一些代码,结果放在错误的地方。
This isn't specific to your question, I know, as your error relates to the <body>
tag, but this is the kind of thing you're looking for. Maybe you have a <link>
or <meta>
tag in your body somewhere, that's meant to be in the <head>
. Without seeing your code, it's hard to give you a perfect answer.
我知道,这不是针对您的问题,因为您的错误与<body>
标签有关,但这是您正在寻找的类型。也许你身体的某个地方有一个<link>
or<meta>
标签,这意味着在<head>
. 没有看到你的代码,很难给你一个完美的答案。
回答by itsmequinn
One of the widgets (the facebook like button I believe) you're using is inserting HTML into the page and part of that HTML is a body tag. Not sure if there's anything you can do about this, but I think that's what's throwing the error. Looks like this:
您正在使用的小部件之一(我相信像 facebook 的按钮)是将 HTML 插入到页面中,并且该 HTML 的一部分是正文标记。不确定您是否可以对此采取任何措施,但我认为这就是引发错误的原因。看起来像这样:
<body class="plugin transparent_widget ff4 win Locale_en_US">
</html>
</iframe>
回答by moyarich
I got this error:
我收到此错误:
A head start tag seen but an element of the same type was already open
看到了一个开头标签,但相同类型的元素已经打开
I read this post and then i noticed my tag listed before the head like this.
我读了这篇文章,然后我注意到我的标签列在这样的头部之前。
<title>Home</title>
<head>
</head>
it should have been
<head>
<title>Home</title>
</head>
回答by alex
I got the same error message : check out if any body-inside <element>
is displayed between the <head>
and <body>
, like said above.
我收到了相同的错误消息:检查是否有 body-inside<element>
显示在<head>
和之间<body>
,如上所述。
My error was caused by a <div>
tag, with absolute position, to display some page information during the development - simply a line ona false positionin the code.
我的错误是由一个<div>
具有绝对位置的标签引起的,它在开发过程中显示了一些页面信息 - 只是代码中错误位置上的一行。
回答by JimXC
In my case it was the facebook tag
就我而言,它是 facebook 标签
<div id="fb-root"></div>
which was inside the page's <head>
.
这是在页面的<head>
.
Moved that to the <body>
of the relevant page (not required globally) sorted it. So yes, the answer supplied above by Emil H was correct.
将其移至<body>
相关页面(全局不需要)对其进行排序。所以是的,上面由 Emil H 提供的答案是正确的。
回答by mokista
Hi in my case hgroup tag is the reason why I'm having validation error I, remove this tag from head tag and put it inside after body tag after this the document is now valid.
嗨,在我的情况下,hgroup 标签是我遇到验证错误的原因,我从 head 标签中删除此标签并将其放在 body 标签之后,文档现在有效。
回答by Yuliia Ashomok
I had similar problem with <head>
tag. I use https://validator.w3.org
我有类似的<head>
标签问题。我使用https://validator.w3.org
Look at few examples how to solve this problem:
看几个例子来解决这个问题:
<script>
should be inside<head>
<script>
应该在里面<head>
- css should be inside
<head>
- css应该在里面
<head>
回答by Aónio
Just for the record, I had exactly the same problem and it seems that including some php files within the head element was strangely giving the problem, even if the view-source of Firefox was not printing such php code nor tags
只是为了记录,我遇到了完全相同的问题,似乎在 head 元素中包含一些 php 文件奇怪地给出了问题,即使 Firefox 的视图源没有打印这样的 php 代码或标签
<head>
<? include("./file.php"); ?>
<title><? echo $title ?></title>
</head>
solved using:
解决使用:
<? include("./file.php"); ?>
<!DOCTYPE html>
<html>
<head>
<title><? echo $title ?></title>
</head>
<body>
...
...
回答by Romynul Shuvo
If Your problem With head and body both are show validate error just remove displaying text from head and keep it in body.. I have been faces the problem recently. For Example You have text to display in header inside head just remove header from head and keep it in body ......Problem solved...Thanks
如果您的 head 和 body 问题都显示验证错误,只需从 head 中删除显示文本并将其保留在 body 中。我最近遇到了这个问题。例如,您有文字要显示在头部内部的标题中,只需从头部删除标题并将其保留在正文中......问题已解决......谢谢