Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label without for can be false positive #104

Closed
DominicCronin opened this issue Oct 8, 2014 · 3 comments
Closed

label without for can be false positive #104

DominicCronin opened this issue Oct 8, 2014 · 3 comments

Comments

@DominicCronin
Copy link

The code sniffer reports an error if a "label" element does not have a "for" attribute. The relevant guideline (http://www.w3.org/TR/2008/REC-WCAG20-20081211/#content-structure-separation-programmatic) requires only that the relationship be programatically determined.

In HTML (http://www.w3.org/html/wg/drafts/html/CR/forms.html#the-label-element), the relationship between a label and its labelled control can also be determined by containment rather than by using a for attribute. The two techniques are equivalent ways of establishing the same relationship in serialised HTML, and once the DOM is parsed, the two techniques are indistinguishable.

The containment technique is a useful one, as it removes the need to generate large amounts of unnecessary ids, and manage their uniqueness. Obviously, it would be better if using this technique didn't result in false positives.

@luketw
Copy link
Member

luketw commented Oct 27, 2014

Hi Dominic,

In the WCAG 2.0 techniques document, the method of implicitly associating labels with a form element by wrapping the LABEL element around the element was actually considered a failure, but this was changed in the March 2014 edition.

See the March 2014 version of F68 vs. September 2013 version). Note two things:

  • In the latter version, the wrapping with label version was considered a failure (Failure Example 2).
  • In the new version, it's now considered a legitimate method of associating a label with a form control (Procedure, 2(b)).

So I agree that this needs to be allowed.

@luketw
Copy link
Member

luketw commented Oct 27, 2014

I'm going to close this off as I'm going to merge it with #107, which is going to be the "master rewrite" issue for the "labels on inputs". There were other things to do with aria-labels that I have to include in there too.

@luketw luketw closed this as completed Oct 27, 2014
@DominicCronin
Copy link
Author

Thanks for fixing this. Always nice when someone "out on the Internet" takes your report seriously. Keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants