Skip to content Skip to sidebar Skip to footer

Ie Doesn't Support Relative Paths In The Base Element When Referencing Css Files

I have a site that uses a base tag to set an absolute path for relative URLs. It works fine in all the browsers I tested it in, except IE (big surprise). Based on the request that

Solution 1:

I don't know for sure if this is your issue in IE or not, but according to relevant portion of the HTML 4.01 standards document, the URL in the base href must be an absolute URI. Further, in the example, given it looks like this (with a filename on it):

<!DOCTYPE HTMLPUBLIC"-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><HTML><HEAD><TITLE>Our Products</TITLE><BASEhref="http://www.aviary.com/products/intro.html"></HEAD><BODY><P>Have you seen our <Ahref="../cages/birds.gif">Bird Cages</A>?
 </BODY></HTML>

In Google searches, I found discussion of what version Firefox added support for relative paths in the base href (which is what you are using) so that is clearly not something that has always been there and not something the 4.01 standard appears to describe.

The HTML5 spec seems to describe and allow base URLs to not have a host portion (host relative) so perhaps that is something that has been added to the specs recently which IE has not supported yet or has not fully supported yet for CSS file loading.

I would suggest you try putting your domain in the base HREF.

Solution 2:

According to html specs: http://www.w3.org/TR/html401/struct/links.html refer: Path information: the BASE element section - This attribute specifies an absolute URI that acts as the base URI for resolving relative URIs.

Chrome and Firefox supports relative paths in this tag but IE does not. IE is following the specs strictly.

To manipulate and include absolute url in the base tag, just include script tag after <head> tag as given below

<scripttype="text/javascript">document.write("<base href='" + window.location.href.substring(0, location.href
        .indexOf("/context") + 9) + "' />");
</script>

Post a Comment for "Ie Doesn't Support Relative Paths In The Base Element When Referencing Css Files"