Whats the difference between input text field and form element in HTML?

Whats the difference between input text field and form element in HTML?
0

#1

Im really curious about it, since i dont see any difference. Is form element even important and useful, and if so how is it usefull and why?


#2

Well the actual tags themselves are different in the sense that a form tag isn’t an input field. You should just google the form tag, it will show you all the properties it takes and the input one as well.


#3

Inputs (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) generally go inside forms (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form).

The form element ties together a number of different inputs that will be submitted together.


#4

The form element is imporant since it allows you to submit information to a server for further processing. For example a login/registration form or a contact us form. The form and input elements work together to complete a task. See the code example below,

<form action="/submitform" method="post">
<input type="text" name="subject">
<input type="email" name="email">
<textarea name="content" cols="100" rows="20"></textarea>
<input type="hidden" name="anti-csrf-token" value="j3d58309kk834905">
<input type="submit" />
</form>

You’ll have to add server side code to process the form, it’s outside the scope of this answer but you could read more about this at https://guide.freecodecamp.org/html/html-forms and https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/forms


#5

Ok i get, so basically if you want your server to collect data/details of visiting user when he registers. Is this correct?


#6

Btw can i write code like this?

form action=' '/submit-home-adress' '><input type=' 'text' ' placeholder=' 'Put your home adress here' '></ form>??