页面中的多个表单标签或一个表单标签? [英] multiple form tags in page or one form tag?

查看:402
本文介绍了页面中的多个表单标签或一个表单标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用HTML5,并且一般都想知道 ,如果我们应该为每个网页使用一个< form> 标签或多个表单标签。



也许这取决于情况,但这里有两种不同的情况:


  1. 一个注册表单

  2. 包含多个子表单的主页:登录,加入邮寄列表等。

在另一个表单标签中放置一个表单标签还是不错,或者每个标准都可以?

谢谢

编辑
您能否以简单的方式解释表单标记的用途是什么?

解决方案

我觉得您已经回答了您的问题。


  1. 注册form = one form tags 。

  2. 多个表单=多个表单标记。

请勿将它们嵌套。 / p>

编辑

表单标签用于存放各种字段(即,输入标签),您最终将使用GET或POST请求传递给目标网址。



以下面的登录表单为例:

 < form action =login.php> 
< input id =nametype =textname =name>
< input id =passwdtype =passwordname =passwd>
< input type =submitvalue =Login>
< / form>

这有一个登录名,一个密码和一个提交按钮。当按下登录按钮(type =submit)时,表单将获取该信息并将其发送到另一个URL(本例中为login.php),该URL将相应地处理信息(例如验证,登录后,显示验证码)。


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?

解决方案

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).

这篇关于页面中的多个表单标签或一个表单标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆