Why is <form> tag useful when we can directly use <input> tag? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why is <form> tag useful when we can directly use <input> tag?

14th Jun 2018, 6:06 PM
Sam - avatar
2 Answers
+ 1
Form groups all the inputs and submit them to server.
15th Jun 2018, 1:24 AM
Calviղ - avatar
+ 1
It's standards pedantics. The statement is legitimate as far as the standard goes: in HTML 4.01, the definition for <form> specifies that it may only contain block elements or <script>. As far as what every browser in the world allows, it's fine. I can only guess that they consider <form> to not be a layout tag at all, and they want all inline elements to be contained inside a block element. Yes, you're supposed to place a <div>, <table>, <p>, or some other block presentational element inside the <form>. https://stackoverflow.com/questions/5439078/why-is-an-input-tag-not-allowed-directly-within-a-form-tag https://www.quora.com/In-coding-why-do-we-need-to-use-the-form-tag-to-put-an-input-in-HTML
14th Jun 2018, 6:10 PM
Alexander Sokolov
Alexander Sokolov - avatar