html - 您如何正确标记用于填写句子的下拉菜单?
问题描述
我有一组单选按钮来选择事件的频率,其中一个如下:
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mondayMonthly" id="mondayMonthly">
<label class="form-check-label" for="mondayMonthly">
<select class="form-control-inline" id="mondayMonthlyNumber" name="mondayMonthlyNumber">
<option>1st</option>
<option>2nd</option>
<option>3rd</option>
<option>4th</option>
<option>5th</option>
</select>
Monday of the month</label>
</div>
结果:
与之交互的流程如下:
- 选择一个单选项目。
- 在单选按钮的标签中,选择事件是否在每月的第 1、第 2、第 3……星期一发生。
将其标记为可访问性的最佳方法是什么?我在想有一些版本的aria-
属性,也许for=""
这会使这项工作,但我真的不知道从哪里开始。
谢谢!
解决方案
假设会有不止一组收音机/选择,我会这样标记:
<fieldset class="form-check form-check-inline">
<legend>Choose frequency</legend>
<p>
<input class="form-check-input" aria-label="monday monthly" type="radio" name="mondayMonthly">
<select class="form-control-inline" aria-label="which monday of the month">
<option aria-label="first">1st</option>
<option aria-label="second">2nd</option>
<option aria-label="third">3rd</option>
<option aria-label="forth">4th</option>
<option aria-label="fifth">5th</option>
</select>
<span>Monday of the month</span>
</p>
<p>
<input class="form-check-input" aria-label="tuesday monthly" type="radio" name="mondayMonthly">
<select class="form-control-inline" aria-label="which tuesday of the month">
<option aria-label="first">1st</option>
<option aria-label="second">2nd</option>
<option aria-label="third">3rd</option>
<option aria-label="forth">4th</option>
<option aria-label="fifth">5th</option>
</select>
<span>Tuesday of the month</span>
</p>
<p>
...
</p>
</fieldset>
推荐阅读
- javascript - 为什么子组件没有在组件树中更新?
- flutter - Flutter:确保首先调用 FirebaseApp.initializeApp(Context)
- xslt - 如何在 XSLT 中的连字符前获取字符串
- mysql - 如何对多个 NULLABLE 列进行唯一索引约束?
- azure-devops - 在 azure 管道 yaml 脚本中使用运行时表达式
- android - 非空类型中的空
- c# - 无法从程序集“EntityFramework,版本=6.0.0.0”加载类型“System.Data.Entity.DbExtensions”
- reactjs - 无法在 react-native 中捕获错误
- c# - ICE:尝试添加同名但类型不同的本地变量。[_RegisterClipboardFormat] 期间
- ios - iOS:我可以以编程方式决定与哪个组件交互(滚动)吗?