Why is an input tag not allowed directly within a form tag?

后端 未结 4 1132
我寻月下人不归
我寻月下人不归 2020-12-17 21:50

I just read the following at http://w3fools.com/#html_forms:

Non-block-level elements (such as ) are not valid directly insi

4条回答
  •  执笔经年
    2020-12-17 22:23

    First of all I'd like to mention that it's not really surprising that HTML tutorials teach you to do things wrong – HTML was practically designed to accept any and every way of doing things. You can leave tags unclosed, you can nest them improperly and whatnot, which is one of the reasons I personally use XHTML.

    That statement seems to be true, but because of how HTML is designed, it does not matter in practise. XHTML probably prohibits this.

    Form isn't really a container of any sort. It seems like the creators of the HTML spec were fond of things like block-level elements you should wrap everything inside of. This is just my view on it, though, but as far as I've noticed, non-block-level elements shouldn't be used without a proper container for them. It's exactly like you shouldn't put non-block-level elements in a

    . Block-level-elements are containers for other elements.

    A div, a table – I think even a

    does the thing here.

提交回复
热议问题