定位表单元素_表单元素

定位表单元素

Unfortunately when the HTML was being designed for forms consistency was not a high priority. You will find that most form-specific tags are <input> tags, but there are several notable exceptions.

不幸的是,在设计HTML以实现表单一致性时,它并不是一个高优先级。 您会发现大多数特定于表单的标记是<input>标记,但是有几个值得注意的例外。

The main points to remember about forms are as follows:

关于表格要记住的要点如下:

  • a form starts with a <form> tag and closes with a matching </form> tag. Form elements (text fields, drop-down menus, etc) can be placed anywhere on the page, with or without a surrounding form tag.

    表单以<form>标记开始,并以匹配的</form>标记结束。 表单元素(文本字段,下拉菜单等)可以放置在页面上的任何位置,带有或不带有周围的form标签。

    The form tag has two attributes that are typically added: method and action.

    form标记具有两个通常添加的属性: methodaction

    A form’s method is the way the submitted data is passed to whatever will be processing it (a CGI script, a script, etc). Often, this method will be post. Alternatively, the get method appends the data to the URL itself when it is submitted, which is obviously less secure (but helpful, if you are interested in debugging a form or bookmarking a page created through a form decision).

    表单的method是将提交的数据传递到将要处理它的对象(CGI脚本, 脚本等)的方式。 通常,此方法将是post 。 另外, get方法在提交数据时会将数据附加到URL本身,这显然不太安全(但是,如果您有兴趣调试表单或为通过表单决策创建的页面添加书签,则很有用)。

    The action attribute of the form tag tells the form where to submit its data to. If a CGI script written in Perl was processing the data, the action attribute would typically be set to something like cgi-bin/form.pl. If a PHP script, it would be something like formhandler.php.

    form标签的action属性告诉表单将​​数据提交到哪里。 如果用Perl编写的CGI脚本正在处理数据,则通常将action属性设置为cgi-bin / form.pl之类的内容 。 如果是PHP脚本,则类似于formhandler.php

The first step in creating our form is the opening and closing <form> tags, with the correct attributes:

创建表单的第一步是打开和关闭具有正确属性的<form>标记:

<form method="post" action="formhandler.php">
</form>

fieldset is a container element inside the form. Think of filling out your tax form at the end of each year: each major section of the form (personal information, employer, income) is divided into a seperate box. fieldset is that box in the context of a form. A form may contain multiple fieldsets.

fieldset是表单内的容器元素。 考虑在每年年底填写税表:该表的每个主要部分(个人信息,雇主,收入)都分为一个单独的框。 fieldset是表单上下文中的那个框。 一个表单可以包含多个fieldset

Immediately inside the fieldset you should enter a <legend> tag, with appropriate content. The <legend> is essentially the label for the entire fieldset, and typically indicates the purpose of that section. (“Personal information”, “Mailing Address”, “Billing Info”, etc).

fieldset立即输入一个<legend>标记,其中包含适当的内容。 <legend>本质上是整个fieldset的标签,通常指示该部分的目的。 (“个人信息”,“邮寄地址”,“账单信息”等)。

The complete setup code for a form is therefore:

因此,表单的完整设置代码为:

<form method="post" action="formhandler.php">
	<fieldset>
		<legend>Legend for form</legend>
		<!-- form content goes here -->
	</fieldset>
</form>

fieldset and legend are optional, but they are useful elements.

fieldsetlegend是可选的,但它们是有用的元素。

翻译自: https://thenewcode.com/163/The-Form-Element

定位表单元素

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值