Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

When using empty URL fragment links, to send a user to the top of the page (e.g. <a href="#">return to top</a>), are these links considered broken or invalid? One of my tools is returning them all as broken links.

share|improve this question
What "tool" is considering them broken? –  w3d Jan 17 '13 at 16:55
A PHP program I use to generate a sitemap. –  Nathan Jan 17 '13 at 17:08
@Su': why did you delete my thanks? I was sincere! –  Nathan Jan 17 '13 at 19:35
@Nathan I'm sure you were. But the SE sites aren't really discussion forums and it's basically a waste of time and space. Just ask the question. Show your appreciation by upvoting/accepting answers. Jeff's answer there is the "canonical" one, but see some of the others for different takes. –  Su' Jan 17 '13 at 20:01
add comment

2 Answers

up vote 10 down vote accepted

Technically, "#" is a well-defined URL reference that points to the start of the current document, so it is not “broken” in formal sense. It can, however, be regarded as bad for accessibility, and it is also a common symptom of “fake” links, i.e. a elements that are supposed to link to something external but depend on JavaScript. (In the very old days, <a href="..." onclick="..."> was the only kind of element that supported the onclick attribute, so people wrote the “dummy” href="#" attribute, which isn’t really dummy.)

So you can regard this as an incorrect error message, or as a useful warning message that might be a little poorly formulated.

share|improve this answer
Do you have a source for # being well-defined and pointing to the start of the document (i.e. a w3c spec)? –  DisgruntledGoat Jan 17 '13 at 23:23
@DisgruntledGoat, it’s specified in Internet-standard STD 66, “Uniform Resource Identifier (URI): Generic Syntax”, clause 4.4. Same-Document Reference, available e.g. at tools.ietf.org/html/std66#section-4.4 –  Jukka K. Korpela Jan 17 '13 at 23:29
Kudos for providing a source, although I don't see anything that specifies # on its own refers to the start of the document. –  DisgruntledGoat Jan 18 '13 at 15:18
Well, yes, the standard isn’t too clear about it, but it’s natural to assume that a referenced document is initially positioned at the start. Its predecessor RFC 2396 was more explicit: “4.2. Same-document References. A URI reference that does not contain a URI is a reference to the current document. In other words, an empty URI reference within a document is interpreted as a reference to the start of that document, and a reference containing only a fragment identifier is a reference to the identified fragment of that document.” –  Jukka K. Korpela Jan 18 '13 at 18:09
add comment

I don't think it is considered as broken link.

Broken link is a link that points to resources doesn't exist (404 HTTP response).

share|improve this answer
Don't hedge this answer with "In my opinion". It's not a matter of opinion, it's a matter of fact (and you are correct). –  msanford Jan 17 '13 at 16:36
@msanford: You're right, I edited my answer. –  Zistoloen Jan 17 '13 at 17:09
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.