ShellRox ShellRox - 10 days ago 9
HTML Question

Is it correct to use FORM to the INPUT that is inside DIV?

I have been wondering about usage of HTML

<form>
tag. I needed it for my
<input>
elements that are inside
<div>
containers.

<form>
<div id="container1">
<input type="text" name="first" id="name">
</div>
<div id="container2">
<input type="text" name="second" id="surname">
</div>
</form>


Is it correct and natural to do this? would this capture all input elements inside form? If not is there any better way or any other way to achieve this?

Answer

form is a block-level element in HTML. Typically, block-level elements allow both block-level and inline children.

Both div and span are valid children of form.

This link would help you to understand better

http://www.w3.org/TR/html4/struct/global.html#h-7.5.3

but You can always use W3C Markup Validation Service to check your html.

Hope this would help. You can also read about Box Modle for more understanding on this subject.