HTML 4.01 Strict Standards
I just ran this simple code through the w3c validation service (http://validator.w3.org/check). Here is the code I'm running through:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"
>
<html lang="en">
<head>
<title><!-- Insert your title here --></title>
</head>
<body>
<form name="testform" action="/" method="post">开发者_如何学JAVA
<input type="text" name="testfield">
</form>
</body>
</html>
I'm getting the following error on the input field:
Line 10, Column 40: document type does not allow element "INPUT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag
I don't see anything wrong with it. Any ideas?
The problems is with how the FORM
element is define in the DTD:
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
So, it can either have a %block
(except for FORM
) or SCRIPT
element.
And %block
is defined as:
<!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
And the rest:
<!ENTITY % heading "H1|H2|H3|H4|H5|H6">
<!ENTITY % list "UL | OL">
<!ENTITY % preformatted "PRE">
Since your form does not contain any of these as a direct child, the page failed validation.
Played around with it a bit--put a "div" tag around the "input" tag:
<div>
<input type="text" name="testfield">
</div>
精彩评论