[whatwg] Proposal for a link attribute to replace <a href>

Sean Hogan shogun70 at westnet.com.au
Tue Aug 5 18:27:08 PDT 2008


Simon Pieters wrote:
> On Mon, 04 Aug 2008 20:21:01 +0200, Jonas Sicking <jonas at sicking.cc> 
> wrote:
>
>> However if we want to add support for the long list of JS attributes 
>> that exist on <a> elements today on each and every HTML element I 
>> suspect that is going to get messier. Especially considering the 
>> collisions for <base> and <link>. What would myBaseElement.accessKey 
>> do? And is myDivElement.protocol really intuitive what it does?
>
> Also it would quite likely clash with existing content that expects 
> that those attributes don't exist on e.g. divs. (Opera has had 
> problems with some new DOM attributes in WF2 due to legacy.)
>
One idea is to enable all elements to cross-reference to hyperlink ("a" 
or "link") elements.
This could be achieved with a "link" attribute that contains the ID of 
the hyperlink element.
The behavior of elements with @link would be UA defined, but could be:
  onclick: follow the hyperlink on the referenced "a" or "link" elemenr
  oncontextmenu: offer menu options to a) scrollTo the hyperlink element 
or b) follow the hyperlink.

If the link attribute is present but empty then it could be assumed to 
reference getElementsByTagName("a")[0].

Pros:
- don't need to add properties of hyperlink elements to other elements
- Javascript implementations for older browsers would be trivial
- the link attribute can be used as a styling hook
- multiple elements can use the one hyperlink


Cons:
- won't inherit :visited styles




More information about the whatwg mailing list