Who says it's not w3C compliant?
As is, it validates fine in HTML.
If you are using XHTML, which you should only do if you need to use XHTML features, the only thing invalid there is H1 is in caps and needs to be h1.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<!-- doctype on one line of course -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<h1><a href="mypage.htm">My Title</a></h1>
Validates fine. This will probably get moved to HTML/Browsers or accessibility, somewhere in there . . . . but don't see a real problem with this approach. See recent related discussion [webmasterworld.com]
I can think of no justification for a hyperlink inside an <h1>.
The <h1> is the top-level heading on the page. What would it be linking to except itself? If you have multiple <h1>s or if they don't encapsulate the main topic of the page, your semantics are off. That can potentially throw off screen readers— and search engines— which is presumably why this thread was moved to the Accessibility & Usability forum.
|I can think of no justification for a hyperlink inside an <h1> |
I can't either, it just doesn't seem correct but it is allowed.
<h2> thru <h6> yes, but not <h1>.
Where would you link it to? Same page? Nah, can't do that.
i could see a case for linking to a fragment identifier on the page.
for example a page displaying the header element followed by a large image followed by the relevant text.
It doesn't seem like such a strange use case to me...what about something like this?
|<h1><a href="/obama.html" title="About Barack Obama">Barack Obama</a> Elected!</h1> |
The hypothetical document with the above heading is a document about somebody getting elected, while the linked page is perhaps a document detailing the subject's biography or CV...*
*Admittedly, the link text in the example above is not that great, but I think the principle is sound...
Perhaps using the H1 as the example was misleading, I agree that the H1 on page "should" be specific to the page that it resides on.
While H2's thru H6's can link out to other relevant pages.
A heading usually sits above, and introduces, the following paragraph, list, table, form, or image (or combination of).
There's little reason for it to link to some other page.
I would put an anchor tag on an h1 but just with a name attribute for a "return to top" link. For "h" tags more generally I can't see why it should be an issue although I would typically link from content underneath a header rather than for the header itself.
That's fine. It links to same page. Main discussion was about linking to a different page.