![How to Design Accessible Forms with HTML and CSS](https://img.php.cn/upload/article/000/000/000/173615974462654.jpg)
目录
- 简介
- 表单的组成部分
- 使用 HTML 的无障碍表单
- 结论
介绍
表单是构建网站不可或缺的一部分。它们用于在用户提交详细信息时收集数据。表单对于用户提交注册表单、登录表单、订阅时事通讯或发送消息以接收反馈的交互非常重要。创建易于访问的表单对每个人都很重要,尤其是屏幕阅读器,可以毫无问题地填写表单。
表单的组成部分
表单由不同的组件组成,例如
-
form:这是接受所有其他表单元素(如输入标签、提交按钮、文本区域、复选框和单选按钮)的容器
-
input:这是接受用户详细信息的 HTML 元素。根据输入的目的提供输入标签;文本、数字、密码、电子邮件等
<form>
<input type="text" />
<input type="email" />
<input type="password" />
<input type="radio" />
<input type="checkbox" />
<input type="file" />
<input type="range" />
<input type="color" />
<input type="date"/>
</form>
登录后复制
-
label:此标签给出了填充输入的详细信息的轮廓。它与输入标签相关联。
<form>
<label for="email">Email</label>
<input type="email">
登录后复制
-
textarea: this is an multi-line input tag that accept 524,288 characters by default except the maxlength attribute is set up to a value. It is used to accept reviews, messages and comments from the users
<form>
<label for="message">Message:</label>
<textarea>
登录后复制
-
select: this element is for creating a dropdown in which the users are able to select one option by default or more options when the attribute multiple is being used.
-
checkbox: this element allow users to select one or more options.
<form>
<label for="subscribe"></label>
<input type="checkbox">
登录后复制
-
button: this tag will the users the opportunity to submit their details upon completion. These details are submitted to server.
<form>
<button type="submit">Submit</button>
</form>
登录后复制
使用 HTML 的可访问表单
使用正确的语义标签,例如
以上是如何使用 HTML 和 CSS 设计可访问的表单的详细内容。更多信息请关注PHP中文网其他相关文章!