2012-03-03 103 views
4

虽然我收到了一些无效的标记错误,但我试图验证我的html5文档。html5验证错误输出

我的代码如下:

<?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE html> 
    <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]--> 
    <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]--> 
    <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]--> 
    <!--[if (gte IE 9)|!(IE)]><!--> 
    <html lang="en"> 
    <!--<![endif]--> 
    <head> 
    <meta charset="utf-8"> 
    <title>index</title> 
    <meta name="description" content=""/> 
    <link rel="stylesheet" href="assets/css/base.css"> 
    <script type="text/javascript" src="assets/js/jquery-1.6.1.min.js"></script> 
    <script type="text/javascript" src="assets/js/jquery-ui-1.8.16.custom.min.js"></script> 
    </head> 

的错误是:

Line 7, Column 16: application/xhtml+xml is not an appropriate Content-Type for a document whose root element is not in a namespace. **<html lang="en">** 

    Line 7, Column 16: Unnamespaced element html not allowed in this context. (Suppressing further errors from this subtree.) **<html lang="en">** 

    Line 16, Column 3: required character (found h) (expected l) **</head>** 

一些专家的建议是高度赞赏。

谢谢 帕特里克

+1

删除'<?xml version =“1.0”encoding =“UTF-8”?>'它应该被验证。 – Aaron 2012-03-03 07:10:34

+0

这很快 - 感谢一群亚伦 - 它的工作! – 2012-03-03 07:13:36

回答

2

HTML5是HTML不是XHTML(XML),所以<?xml ... ?>导致验证问题(如亚伦已经说过)

1

只是XHTML命名空间添加到HTML元素,如这个:<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
您的代码仍然无效,因为您忘记将其他反斜杠添加到void元素(元和链接)。