Creating Form element

Creating Form element
0.0 0

#1

why is it necessary to use <form></form> syntax ? when we can directly type <input type="text".


#2

A form element is necessary to submit the form to the server. If you are just trying to have markup and access the markup via JavaScript, then you don’t technically need a form. However, if you want to submit the form to a server via the traditional way, you need a form element.

<!-- you can't do anything with this really -->
<input type="text" name="firstname"/>
<input type="email" name="email"/>

<!-- But you can submit these values to a webserver -->
<form action="/server_route.php">
  <input type="text" name="firstname"/>
  <input type="email" name="email"/>
</form>