简体   繁体   中英

can't figure out why HTML won't validate

I'm getting 2 errors:

end tag for "FORM" omitted, but its declaration does not permit this:

and

end tag for element "FORM" which is not open:

but I thought I closed both of them properly.

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>

Just switch your div and form tag.

You're opening the div:

<div class="t1">

then opening the form:

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

then closing the div:

</div>

and closing the form:

</form>

Instead the correct order is open the div, open the form, closing the form, closing the div.

Tags are contained in each others like in a Matryoshka doll .

You have wrong nestings of your outer div (class="t1") and form. It should be like this at the end:

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

and not:

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

because the div tag is opened before the form.

You're closing the last <div> in the wrong place. Move it bellow the </form> tag.

Also, try to use and CSS instead of
and

<!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>

i had this kind of bug and couldn't also validate my document... the best way in this case is to put the open form Tag directly after the open ody tag and the closing form Tag directly before the closing body Tag. something like this:

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

And i would use the fieldset, label and legen etc. Adding structure to forms: the FIELDSET and LEGEND elements

Amin Kasbi

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