加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – 为什么有人想在表单中包装表单元素?

发布时间:2020-12-14 23:10:38 所属栏目:资源 来源:网络整理
导读:例如.这是简单的形式(我经常使用): 但我读了一些书,看到我的一些朋友经常这样做: 不同之处在于:它们经常将所有组件包装在div标签内,然后为其分配一个类名(尽管div标签内部只有一个组件).我不知道他们这样做有什么好处. 谢谢 :) 最佳答案 WHATWG: 4.10.1.

例如.这是简单的形式(我经常使用):

但我读了一些书,看到我的一些朋友经常这样做:

不同之处在于:它们经常将所有组件包装在div标签内,然后为其分配一个类名(尽管div标签内部只有一个组件).我不知道他们这样做有什么好处.

谢谢 :)

最佳答案
WHATWG: 4.10.1.1 Writing a form’s user interface

Any form starts with a form element,inside which are placed the controls. Most controls are represented by the input element,which by default provides a text control. To label a control,the label element is used; the label text and the control itself go inside the label element. Each part of a form is considered a paragraph,and is typically separated from other parts using p elements. Putting this together,here is how one might ask for the customer’s name:

WAI: Forms > Grouping Controls

Grouping related form controls makes forms more understandable for all users,as related controls are easier to identify… In this example,the div element has role=group to indicate that the contained elements are members of a group and the aria-labelledby attribute references the id for text that will serve as the label for the group…

它还建议使用< fieldset>和< legend>元素. <字段集> element为相关的表单控件提供了一个容器,< legend> element用作标识组的标题.

除此之外,样式和操作是许多开发人员的主要原因.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读