tags:

views:

271

answers:

2

This below code is forbidden in XHTML 1.1 strict mode:

<form method="post" action="index">
    <input id="_method" name="_method" type="hidden" value="" />
</form>

if you want it to be valid you need to put a div (or p, etc..) like:

<form method="post" action="index">
    <div>
         <input id="_method" name="_method" type="hidden" value="" />
    </div>
</form>

Why this is make sense at all?

+4  A: 

According to the W3C and this site the <form> element in XHTML 1.1 may only contain block level elements and <fieldset>.


As for why ... I believe that the reason that form may only contain block-level elements is because it is not considered an element in itself, but rather a wrapper around other elements. There was some discussion of this in the w3c's mailing lists some years ago that I was able to dig up -- but nothing that actually answered the question.

Sean Vieira
+1  A: 

Welcome to the wacky world of standards. Sometimes it seemed like the folks writing XHTML standards thought the language would be better if it had more rules.

HTML5 is here now.

Paul D. Waite
But everyone like XHTML as it is.. With lots of rules... Rules make a better World... Without rules === Without web 3.0 :)
TiuTalk
“But everyone like XHTML as it is” — Very true, there’s certainly no-one looking to make an XHTML 2.0 spec. “Rules make a better World...” — Useful rules do. If XHTML had a rule that documents could only contain `<em>` tags on a Tuesday, that wouldn’t make the world better. “Without rules === Without web 3.0 :)” — Eh?
Paul D. Waite