I am unclear on IE's support for the <base>
tag. Some articles suggest that it only works with an absolute href path. But it won't work for me.
<base href="http://domain.net/qu/en/" />
<a href="sample">Sample Link</a>
On chrome and FF, clicking on the link will take me to http://domain.net/qu/en/sample
but in IE9, it's taking me to http://domain.net/qu/sample
I tried this with a relative <base>
as well, and it doesn't appear to work.
I have only tested this in IE9.08
The HTML base tag is used to specify a base URI, or URL, for relative links. This URL will be the base URL for every link on the page and will be prefixed before each of them. For example, if the URL specified by the base tag is “www.xyz.com” and then every other URL on the page will be prefixed by, “www.xyz.com/”.
The <base> tag is empty, which means that the closing tag isn't required. But in XHTML, the (<base>) tag must be closed (<base/>). Only one <base> tag can be used on the page, and it must be placed in the <head> element.
IE has always supported <base href>
. By the specifications, it has always been defined only when the href
value is an absolute URL, though some browsers have had interpreted it even in the case of a relative URL. It must be placed in the <head>
part of the document; otherwise browsers may ignore it. The base address can only be set once in a document. (If this is violated, browsers tend to ignore all but the first of them.)
In this case, my guess is that there is some character, outside any tags, before the <base>
tag. Consider this:
<base href="http://domain.net/qu/en/" />
<a href="sample">Sample Link</a>
This is invalid because of the no-break space character before the <base>
tag. In HTML parsing, the no-break space, which is not a whitespace character, implicitly closes the <head>
element and opens the <body>
element. This means that the <base>
tag would now be in the <body>
. Some browsers may still accept it, but as the document cited in Tieson T’s answer says: “Internet Explorer 7 [and newer] strictly enforces the use of the base tag within the head of the document, and will ignore misplaced tags.”
To check things out, use a validator—it will among other things report problems like this.
According to Microsoft, IE 7 and newer do: http://msdn.microsoft.com/en-us/library/ms535191%28v=vs.85%29.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With