What is the correct code for turning a h1, h2 etc heading into a link and search engines
index texts of header and link both?
Is it:
<a href="#"><h1>heading</h1></a>
or
<h1><a href="#">heading</a></h1>
and could anyone explain why ?
What is the correct code for turning a h1, h2 etc heading into a link and search engines
index texts of header and link both?
Is it:
<a href="#"><h1>heading</h1></a>
or
<h1><a href="#">heading</a></h1>
and could anyone explain why ?
Per here: http://www.w3.org/TR/html401/struct/global.html#h-7.5.4
%flow
element which display as a block (in this case<h1>
) always should surround%inline
elements (such as<a>
).Another example
<div>
should always be outside<span>
.That is to say:
is correct.
An even easier way of under standing this is that the following makes sense:
It would be highly unusual to try the inverse with multiple
<h1>
s inside an<a>
.If You go with code1
you are just able to make it as a link with highlight feature. But If you go with code2
you will probably able to satisfy some css property as h1 a{ //hover or text decoration}
I will go with second code. ... Both will work.