Can a form tag enclose a body tag?

I went through some code today that had a form tag before the body tag. I mean the form tag has closed the body tag. Is it possible? If so, where is it useful?

<form  action="someaction.jsp" method="post">
 <body>
  ...
 </body>
</form>

      

+3


source to share


4 answers


By examining the description of W3C Recommendations

Form elements , it clearly shows that you better not use this method.

You can use the element Form

in:

The contexts in which this element can be used: where the content of the stream is expected.

Where Stream Content is described as:



Most of the elements that are used in documents and applications are classified as flow .

Therefore, without following these guidelines, any HTML validators will also report errors to you, as the forms opening the closing tags were not found in the side of the body definition. This is perfectly true since:

Missing tags in text / html: No tags are valid.

+3


source


The browser follows a forgiving approach, but when I use it against a validator, it just throws these errors. It's always good to follow standards or browsers get confused.



Errors in W3C Validator

+2


source


Browsers tend to be very forgiving when it comes to errors in HTML structure, so it is possible and the form may still work, but it is still incorrectly HTML-coded and won't be useful for anything in particular.

+1


source


Yes it is possible; the browser will shrink it.

But this is not very high HTML syntax and I can't think of any cases where it might be useful. The HTML body is what it says on the label - the global container for the page body.

0


source







All Articles