无法弄清楚为什么HTML不会验证

时间:2011-10-08 14:36:18

标签: html validation

我收到2个错误:

省略了“FORM”的结束标记,但其声明不允许这样:

元素“FORM”的结束标记未打开:

但我以为我正确关闭了它们。

html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
   <title> Incident Form </title>
   <link rel="stylesheet" href="http:...">
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div class="header">
Incident Form

</div>

<div class="t1">



<form action="connect_database.php" method = post>


<p>
<br><br>
<ins>Be sure to fill in all of the fields</ins>
<br><br><br><br>
</p>

<p>
Choose the type of incident<br>
<br>
</p>

<p>
<input type="radio" name="type" value="afs"> Afs<br>    
<input type="radio" name="type" value="db"> Database<br> 
<input type="radio" name="type" value="cs"> Computer systems<br>
<input type="radio" name="type" value="pw"> Password<br>
<input type="radio" name="type" value="hw"> Hardware<br>
<input type="radio" name="type" value="other"> Other<br>
<br><br><br>
</p>

<p>
Describe the incident<br><br>
<textarea rows="6" cols="20" name="inc"></textarea><br><br>
</p>

<p>
Would you also like to receive an email copy of your form summary?
<br><br>
</p>

<p>
<input type="radio" name="yesno" value="yes"> Yes<br>
<input type="radio" name="yesno" value="no"> No<br>
<br><br>


<input type="submit" name = "submit1" value= "Submit Incident">
</p>


</div>

</form>


</body>
</html>

4 个答案:

答案 0 :(得分:3)

只需切换div和form标签即可。

你正在打开div:

<div class="t1">
然后打开表格:

<form action="connect_database.php" method = post>

然后关闭div:

</div>

并关闭表单:

</form>

相反,正确的顺序是打开div,打开表单,关闭表单,关闭div。

标签包含在Matryoshka doll中,彼此包含在内。

答案 1 :(得分:3)

你的外部div(class =“t1”)和表单有错误的嵌套。最后应该是这样的:

</form>
</div>
</body>

而不是:

</div>
</form>
</body>

因为div标签在表单之前打开。

答案 2 :(得分:1)

您正在关闭错误位置的最后一个<div>。将其移至</form>标记下方。

另外,尝试使用CSS而不是

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
   <title> Incident Form </title>
   <link rel="stylesheet" href="http:...">
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div class="header">
Incident Form

</div>

<div class="t1">



<form action="connect_database.php" method = post>


<p>
<br><br>
<ins>Be sure to fill in all of the fields</ins>
<br><br><br><br>
</p>

<p>
Choose the type of incident<br>
<br>
</p>

<p>
<input type="radio" name="type" value="afs"> Afs<br>    
<input type="radio" name="type" value="db"> Database<br> 
<input type="radio" name="type" value="cs"> Computer systems<br>
<input type="radio" name="type" value="pw"> Password<br>
<input type="radio" name="type" value="hw"> Hardware<br>
<input type="radio" name="type" value="other"> Other<br>
<br><br><br>
</p>

<p>
Describe the incident<br><br>
<textarea rows="6" cols="20" name="inc"></textarea><br><br>
</p>

<p>
Would you also like to receive an email copy of your form summary?
<br><br>
</p>

<p>
<input type="radio" name="yesno" value="yes"> Yes<br>
<input type="radio" name="yesno" value="no"> No<br>
<br><br>


<input type="submit" name = "submit1" value= "Submit Incident">
</p>




</form>
</div>

</body>
</html>

答案 3 :(得分:0)

我有这种错误,也无法验证我的文档......在这种情况下,最好的方法是在打开ody标签后直接打开表单标签,直接在结束标签之前放置结束表格标签。像这样的东西:

<body>
  <form ....>
      ....
  </form>
</body>

我会使用fieldset,label和legen等Adding structure to forms: the FIELDSET and LEGEND elements

Amin Kasbi