igogra
igogra

Reputation: 465

HTML5 error W3C Validator

I get the following error in the W3C Validator:

The for attribute of the label element must refer to a form control

I have the following code:

<label class="description" for="rating-item-3-1">Test</label>
<input id="rating-item-3-1" type="hidden" value="0" name="rating-item-3-1">

I was researching and this error is due to type="hidden". Is there any way to fix this error?

Thanks.

Upvotes: 0

Views: 81

Answers (1)

Barun
Barun

Reputation: 4431

According to w3.org:

The label element is not used for the following because labels for these elements are provided via the value attribute (for Submit and Reset buttons), the alt attribute (for image buttons), or element content itself (button)

  • Submit and Reset buttons ( <input type="submit"> or <input type="reset">)
  • Image buttons ( <input type="image">)
  • Hidden input fields ( <input type="hidden">)
  • Script buttons (<button> elements or <input type="button">)

So, I think you got your answer.

Upvotes: 1

Related Questions