Search code examples
htmlformswcag

WCAG error: broken rule regarding label for email input (What am I missing?)


I keep getting an error in multiple accessibility tests stating that my form doesn't have a label. I added the for="EMAIL" for the label. Am I missing something?

<p>
    <label for="EMAIL">Email address: </label>
    <input type="email" name="EMAIL" placeholder="Your email address" required />
</p>

<p>
    <input type="submit" value="Sign up" name="signup"/>
</p>

Solution

  • The for attribute on the <label> object is designed to be used with an id attribute.

    Try:

    <input type="email" name="EMAIL" id="EMAIL" placeholder="Your email address" required />