Lighthouse error: “Form elements do not have associated labels”

一世执手 提交于 2019-12-11 15:15:28

问题


How do I fix this Lighthouse error:

Form elements do not have associated labels

<input type="text" id="s" name="s" value="Arama..." onfocus="if (this.value == 'Arama...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Arama...';}">

<select id="main-menu-mob">

<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea>

回答1:


For each of these you can add a label that references the element, or use the aria-labelledBy attribute. I think labels are easiest but I will show you one of each. Here is how you would do that.

<label for="s">Arama...</label>
<input type="text" id="s" name="s" value="Arama..." onfocus="if (this.value == 'Arama...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Arama...';}">

<label id="lbl-main-menu-mob">Select Item</label>
<select id="main-menu-mob" aria-labelledby="lbl-main-menu-mob">

<label for="comment">Enter Comment</label>
<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea>


来源:https://stackoverflow.com/questions/56083674/lighthouse-error-form-elements-do-not-have-associated-labels

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!