Delan Azabani
Delan Azabani

Reputation: 81492

specification/implementation behaviour for empty href?

I once read a page a few years ago about the various browsers' differing implementations of behaviour when a link with an empty href is clicked.

...and various other behaviours.

Upvotes: 0

Views: 180

Answers (1)

DVK
DVK

Reputation: 129539

Since there's no "specification" for contents of HREF (at least in HTML 4), the browsers can do whatever they damn well please.

UPDATE However, aside from HTML, there's an RFC3986: Uniform Resource Identifier (URI): Generic Syntax. It has section 4.4. Same-Document Reference which says:

When a URI reference refers to a URI that is, aside from its fragment
component (if any), identical to the base URI (Section 5.1), that
reference is called a "same-document" reference. The most frequent
examples of same-document references are relative references that are empty ...

I do not necessarily read the above as "an empty URI MUST cause the client to reload the same socument's URI", but it does sound like a "best practice" type of wording; so if I was implementing my own browser I'd almost certainly follow such a behavior.

On a related note, here's a good recent 3/2010) roundup of how browsers treat empty src attribute of <img> tag: http://www.nczonline.net/blog/2010/03/16/empty-string-urls-in-html-a-followup/ and http://www.nczonline.net/blog/2010/07/13/empty-string-urls-browser-update/ . Please note that it is a big deal, since having and empty img src would cause the page to endlessly re-load itself in the worst case scenario.

Upvotes: 1

Related Questions