html5 一致性检查器取代了我的文档类型
当我验证我的网页时,有时一致性检查器会验证以下随机代码而不是我的网页。
<!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>
当它执行此操作时,我可以选择“显示源”选项并重新验证页面,直到我的源显示出来,这符合 html5 就好了。
为什么我有时会收到这个随机代码?我通常不会在意,但我的一位教授一直试图因为我不合格而扣掉我的作业。可悲的是,他没有任何关于如何解决这个问题的建议。如果我可以更改代码以避免一致性检查器中的随机替换,请告诉我。
我正在 validator.w3.org 使用检查器
以下是我的代码示例:
<!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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的主机站点是地面吗? - 我有一个客户端有类似的问题,我的假设是,服务器的设置是这样的:如果在发出请求时页面不可用,服务器将返回此通用 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.
您需要专门告诉它使用 HTML5 验证器:
这在通过直接复制和粘贴时对我有用输入。
编辑:还有一个实验性验证器:
http: //html5.validator.nu/
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/