Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does IE not support the base tag?

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

like image 847
HyderA Avatar asked Apr 30 '12 06:04

HyderA


People also ask

What is the base tag used for?

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/”.

Is Base tag an empty tag?

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.


2 Answers

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.

like image 50
Jukka K. Korpela Avatar answered Sep 22 '22 01:09

Jukka K. Korpela


According to Microsoft, IE 7 and newer do: http://msdn.microsoft.com/en-us/library/ms535191%28v=vs.85%29.aspx

like image 30
Tieson T. Avatar answered Sep 20 '22 01:09

Tieson T.