Validating HTML5 Page

时间:2015-07-28 22:36:05

标签: html5 validation

I validated my website using: https://validator.w3.org/#validate_by_upload and I got no errors. However, the website recently changed and now I get these 2 messages:

Info: The Content-Type was application/octet-stream. Using the XML parser (not resolving external entities). Fatal Error: Empty document, with no root element.

What do these messages mean? How do I correct the error?

The settings I used were: Encoding: utf-8 document type: HTML5

SIMPLE HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>


<link href="css/omnicode.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->

</head>

<body>
<div class="container">
  <header>
    <h1>Header</h1>
  </header>
  <hr>
  <p> TEXT </p>
  <hr>
  <footer>Footer</footer>
</div> 
</body>
</html>

3 个答案:

答案 0 :(得分:1)

It could be because you have opening tags that are not closed. I put your code in to the checker and it complained about the body element being found before the div is closed:

<body>
  <div class="container">  <!-- no closing tag for this div -->
  <header>
    <h1>Header</h1>
  </header>
  <hr>
  <p> TEXT </p>
  <div>
  <hr>
  <footer>Footer</footer>
</div> 
</body>
Message filtering
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: End tag for  body seen, but there were unclosed elements.
From line 27, column 1; to line 27, column 7
Error: Unclosed element div.
From line 17, column 1; to line 17, column 23

Fix that and rerun the tests.

答案 1 :(得分:1)

使用旧的w3验证器和Safari作为上传浏览器时,这是一个问题;如果你使用Chrome上传它应该可以正常工作,或者如果你剪切和粘贴它应该工作正常。此外,如果您使用Safari上传到&#34;新学校&#34;验证器它也可以工作。

http://html5.validator.nu/

答案 2 :(得分:0)

It looks fine but some tags need to be closed like your hr's

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>


<link href="css/omnicode.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->

</head>

<body>
<div class="container">
  <header>
    <h1>Header</h1>
  </header>
  <hr />
  <div>
  <p> TEXT </p>
  </div>
  <hr />
  <footer>Footer</footer>
</div> 
</body>
</html>