In XHTML 1.1: element 'input' cannot be ne

2019-02-22 06:16发布

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 then you need to wrap it with a div (or p, etc..) like:

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

How does this make any sense at all?

标签: xhtml
2条回答
可以哭但决不认输i
2楼-- · 2019-02-22 06:25

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.

查看更多
Evening l夕情丶
3楼-- · 2019-02-22 06:27

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.

查看更多
登录 后发表回答