squizlabs/HTML_CodeSniffer — pull request #13 by lwright-sq (2012-06-19 00:49:54+00:00)
Title: "a" elements not acting as a link a should emit a warning, not an error

In SC 4.1.2, we currently emit errors for "a" elements with no link text and a "name" or "id" attribute - being used as an in-page link target - stating it does not fit in with an "a" element's role as a link.

In HTML 4.01 (and XHTML 1.0), an "a" element is only a link if a href attribute is applied to it, thus making it a "source anchor" in a link. "Destination anchors" (eg. ) are defined as "just" anchors, not links. In HTML5, the role of a destination anchor does not exist - it is either a link, or a link placeholder. Use of the "name" attribute is also discouraged as it is considered obsolete in HTML5.

This change softens the errors thrown for "destination anchors" from Error to Warning, with a small message change. The recommendation that they not be used as destinations remains, but the message itself now says what it has found (similar to other link-related tests), rather than straight-out "they should not be used".