0

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.

1
  • 3
    You are adding a label for a hidden field? What kind of behavior are you expecting? Commented Jun 17, 2014 at 16:33

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.