Re: label element for attribute not checked for pointing to form control

Liam Morland wrote:

> In the HTML4 specification, for@ is required to contain the @id of a
> form control, not just any @id in the document:
[...]
> However, the following validates even though the @for points to a div
> element.

The requirement that you cite has not been expressed and cannot be expressed 
in a Document Type Definition (DTD), so markup validation in the classic 
(SGML, XML) sense does not cover it. The @for attribute is declared with 
IDREF type, which means that the value must be match an @id attribute value 
in the document, but there is no further requirement.

In the experimental HTML5 mode, for HTML5 documents, the W3C Markup 
Validator applies a completely different approach, performing a mixture of 
checks, instead of checking conformance to a DTD. In that mode, a situation 
discussed here is reported as an error.

Yuvva 

Received on Tuesday, 3 May 2011 05:06:20 UTC