html - <head> 和 <body> 验证问题

标签 html validation

我认为网页上有一个非常简单的区域,但它未能通过 validator.w3.org 进行验证,我无法找出原因。

完整的源代码可以在http://iapps.smartphonesoft.com查看。

源代码的第一部分是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- TradeDoubler site verification 1xxx -->
<title>iPhone Apps, iPhone Software and Freeware</title>
<link rel="stylesheet" href="/css/style2.css" type="text/css" />
<!--[if IE]>
<style type="text/css"> 
/* place css fixes for all versions of IE in this conditional comment */
.thrColLiqHdr #sidebar2, .thrColLiqHdr #sidebar1 { padding-top: 30px; }
.thrColLiqHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
</head>
<body>

<?php

我得到的错误如下,我想这是一些明显的东西在我面前盯着,但我担心我看不到什么!

Validation Output: 3 Errors

Line 35, Column 7: end tag for element "head" which is not open ✉ The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

If this error occurred in a script section of your document, you should probably read this FAQ entry.

Line 36, Column 6: document type does not allow element "body" here ✉ The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

Line 270, Column 7: end tag for "body" omitted, but OMITTAG NO was specified ✉ You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".

Line 17, Column 1: start tag was here

最佳答案

查看您提供的链接中的代码,问题似乎相当明显 - 您关闭了 <head>元素并打开 <body>元素两次:

</head> 
<body> <!-- first time -->


<script type="text/javascript"> 

  /* some script */

</script> 

</head> 
<body> <!-- second time! -->

关于html - <head> 和 <body> 验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4575636/

相关文章:

html - 字体粗细值无法正常工作

javascript - 如何通过 HTML 和 ajax 中的动态按钮从动态文本框中获取文本

javascript - 如何使用一个新的 Error() 显示多个 javascript 错误?

c - 使用 atoi() 对整数进行输入验证

php - MVC 项目中应该在哪里进行表单验证?

javascript - 无法在 Leaflet map 标记的文本区域内移动插入符号/光标?

javascript - 如何使用 2 个数组创建具有键和值的新数组?

html - 空的 HTML 标签

javascript - 使用javascript进行最小最大验证

javascript - 验证文本区域中超长单词的用户输入