gpt4 book ai didi

html - 使用无序列表创建表单?

转载 作者:搜寻专家 更新时间:2023-10-31 08:22:09 25 4
gpt4 key购买 nike

这是我之前问题的延续,该问题由于与之前的一些 SO 问题相似而被关闭。尽管所有相关问题的答案都让我这么想:

我们应该使用无序列表来创建表单吗?尽管我得到了褒贬不一的评论。

一个特定的博客 http://green-beast.com/blog/?p=259说对表单使用无序列表是不正确的。我想请开发人员对此声明发表评论?

最佳答案

HTML offers authors several mechanisms for specifying lists of information. All lists must contain one or more list elements. Lists may contain: unordered information, ordered information and definitions. (from http://www.w3.org/TR/html4/struct/lists.html#edef-UL)

我认为列表是 HTML 中最重要的元素:从语义上讲,有很多对象都是纯列表。使用 uldlform 对输入字段和标签进行分组也是一个好习惯。

有人会使用段落标记表单:

<form action="" method="post">
<fieldset>
<p>
<label>
Full Name:
<input type="text" name="name" />
</label>
</p>
<p>
<label>
Password:
<input type="password" name="password" />
</label>
</p>
</fieldset>
<fieldset>
<p>
<label>
Occupation:
<input type="text" name="occupation" />
</label>
</p>
<p>
<label>
Location:
<input type="text" name="location" />
</label>
</p>
</fieldset>
<p>
<input type="submit" value="Submit" />
</p>
</form>

然后有人会使用列表对其进行标记(在我看来这看起来非常有机):

<form action="" method="post">
<fieldset>
<dl>
<dt><label for="name">Full Name:</label></dt>
<dd><input id="name" type="text" name="name" /></dd>
<!-- <dd class="error">Some errors/validation warnings</dd> -->

<dt><label for="password">Password:</label></dt>
<dd><input id="password" type="password" name="password" /></dd>
<!-- <dd class="note">Some notes about the field above</dd> -->
</dl>
</fieldset>
<fieldset>
<dl>
<dt><label for="occupation">Occupation:</label></dt>
<dd><input id="occupation" type="text" name="occupation" /></dd>

<dt><label for="location">Location:</label></dt>
<dd><input id="location" type="text" name="location" /></dd>
</dl>
</fieldset>
<p>
<input type="submit" value="Submit" />
</p>
</form>

表单列表(字段列表、分组数据),因为它们具有统一且重复的结构:

INPUT_1
INPUT_2
...
INPUT_N

关于html - 使用无序列表创建表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3379553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com