Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple form tags in page or one form tag?

Tags:

I have just started HTML5 and want to know in general if we should use one <form> tag per web page or multiple form tags.

Maybe it depends on the situation, but here are two different scenarios:

  1. One Sign Up form
  2. A home page with multiple sub forms: Login, Join Mailing List, etc.

Is it bad to have a form tag inside another or is it ok per standards?

Thanks

Edit Can you please explain in a simple way what the purpose of the form tag is?

like image 939
haansi Avatar asked Aug 21 '12 23:08

haansi


1 Answers

I feel like you've already answered your questions.

  1. One sign up form = one form tags.
  2. Multiple forms = many form tags.

Just don't nest them.

EDIT

Form tags are meant to hold a variety of fields (i.e. input tags) that you will eventually pass to a target URL using a GET or POST request.

Take this login form, for example:

<form action="login.php">   <input id="name" type="text" name="name">   <input id="passwd" type="password" name="passwd">   <input type="submit" value="Login"> </form> 

This has a login, a password, and a submit button. When the "Login" button (type = "submit") is pressed, the form will take that information and send it to another URL (in this case, "login.php", and that URL will handle the information accordingly (e.g. validate, sign you in, display captcha).

like image 106
Phil Avatar answered Sep 24 '22 03:09

Phil