Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lighthouse error: "Form elements do not have associated labels"

Tags:

html

forms

label

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>
like image 741
Mehmetk Avatar asked Mar 15 '26 01:03

Mehmetk


1 Answers

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.

<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>
like image 106
JakeofSpades Avatar answered Mar 16 '26 15:03

JakeofSpades



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!