Anchors inside headers or vice versa - is there any difference in SEO?

I always come across this (rather simple question) when creating, for example, Wordpress blogs. Should I wrap the header, which should also be a link, in the <a> anchor element, or should it be the other way around. And why?

(1) :

 <a href="foo"> <h1>bar</h1> </a> 

(2) :

 <h1> <a href="foo">bar</a> </h1> 

I always end up doing (1) , since it seems more logical to me that the title is enclosed in a link.

Does it matter, for example, SEO? Does this reflect SEO rankings?

+80
html semantics seo hyperlink
Nov 17 2018-11-21T00:
source share
2 answers

Before HTML5:
The anchor must be inside the header, you cannot put the block level element in the anchor, and most browsers will not be 100% more reliable to execute it.

In HTML5:
It does not matter, use what makes the most semantic meaning. Probably the first one.

Remember that if your document uses HTML4 DTD, it will not check and may not display correctly because it uses old rules in which the anchor cannot contain a block level element. Use only the first option in HTML5. XHTML is equivalent to HTML4, I'm not 100% sure about XHTML1.1 (try and see if it checks).

+72
Nov 17 '11 at 21:29
source share

If you are using DTD HTML 4.01 (not sure about the transition, but definitely strict), then the anchor element should appear inside the header element. Check your doctype if you don’t know which DTD you are using (assuming you have one that you need so that the oyur code is considered valid). An HTML5 document is as follows:

 <!DOCTYPE HTML> 

4.01 doctype:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 

I also suggest that you familiarize yourself with DTD itself, if you are going to work with 4.01, it will answer all these types of questions.

+7
Nov 17 2018-11-21T00:
source share



All Articles