The href
attribute is indeed only a valid attribute for <a>
, <area>
, <base>
and <link>
(convenient attribute + element reference).
Now that the validity is clear, we can talk about how this could have been (ab)used (still not making it valid).
Using javascript, one could give any attribute meaning, even the invalid ones.
var section = document.querySelector('section[href]'),
href = section.getAttribute('href');
section.innerHTML = 'Could have loaded ' + href + ' here';
<section href="index.html">
default content
</section>
This was a rather common practise before HTML5, abusing valid attributes aswel as introducing invalid ones, simply to implement behaviour with script.
This is why as of HTML5 the W3C/WhatWG (the people who kindly write these specifications) have provided the data-
attribute prefix, which allow to make up attributes which have no meaning (ever) in HTML and are always considered valid.
So, the href
attribute is not valid on a <section>
-element, but it could have been given some meaning using javascript, which is invalid and should have been data-href
(or a name describing its purpose better).