[whatwg] [WA1] The a element could be empty

Simon Pieters zcorpan at hotmail.com
Thu Sep 1 15:31:52 PDT 2005


The spec currently says[1]:

|The a element must not be empty.

I think it would be more useful if it was changed to:

|If the a element has an href attribute set, then the element must not be 

It is easier to use an empty a element as a placeholder to grab and use with 
scripts later on, for instance:

   <a id="print"></a>


   var elm = document.getElementById("print");
   elm.href = "javascript:window.print()";
   elm.appendChild(document.createTextNode("Print this page"));

...rather than to create the link with script from scratch.

Simon Pieters

[1] http://whatwg.org/specs/web-apps/current-work/#the-a

More information about the whatwg mailing list