简体   繁体   中英

html5 conformance checker replaces my doctype

When I validate my web page, sometimes the conformance checker will validate the following random code instead of my web page.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="0.1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<TITLE></TITLE>
</HEAD>
<BODY><P></BODY>
</HTML>

When it does this, I can select the "show source" option and re-validate the page until my source shows up, which conforms to html5 just fine.

Why do I get this random code sometimes? I usually wouldn't care, but one of my professors keeps trying to dock my assignments for not conforming. Sadly, he doesn't have any suggestions on how to fix this. Please let me know if there is something I can change in my code to avoid random substitutions in the conformance checker.

I am using the checker at validator.w3.org

The following is a sample of my code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="/css/default.css" type="text/css" rel="stylesheet" media="screen">
<title>Database Plan</title>
<?php include $_SERVER["DOCUMENT_ROOT"]."/modules/googleanalytics.inc"; ?>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="wrapper">

<header id="header">
<div id="redback">
<?php include $_SERVER["DOCUMENT_ROOT"]."/modules/header.inc"; ?>
</div>
</header>

<nav id="navtop">
<div>
<?php include $_SERVER["DOCUMENT_ROOT"]."/modules/topnav.inc"; ?>
</div>
</nav>

<div id="centerbox">

<div id="article">
<article id="innerarticle">
<div>

<p>Article Content</p>
</div>
</article>
</div>
</div>
<footer id="footer">
<div id="grayback">
<?php include $_SERVER["DOCUMENT_ROOT"]."/modules/footer.inc"; ?>
</div>
</footer>
</div>
</body>
</html>

is your host siteground? - I have a client having a similar issue and my hypothesis is that the server is setup such that if the page is not available at the time the request is made the server returns this generic HTML page with the meta-refresh on it that is imperceptible to the website visitor but is interpreted by the validator.

You need to tell it specifically to use the HTML5 validator:

在此处输入图像描述

This worked for me when copying and pasting through direct input.

EDIT : There is also this experimental validator as well:

http://html5.validator.nu/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM