The <base> tag specifies the base URL/target for all relative URLs in a document.
There can be at maximum one <base> element in a document, and it must be inside the <head> element.
The HTML <base> tag also supports following additional attributes:
|href||URL||Specifies the URL of a page or the name of the anchor that the link goes to.|
|Where to open the target URL.
_blank – the target URL will open in a new window.
_self – the target URL will open in the same frame as it was clicked.
_parent – the target URL will open in the parent frameset
_top – the target URL will open in the full body of the window
</pre> <!DOCTYPE html> <html> <head> <title>HTML base Tag</title> <base href="http://www.musthaan.com" /> </head> <body> HTML: <img src="/images/html.gif" /> </body> </html></pre> <pre>
In this case image request to http://www.musthaan.com/images/html.gif
</pre> <!DOCTYPE html> <html> <head> <title>HTML base Tag</title> <base href="http://www.musthaan.com/external" /> </head> <body> HTML: <img src="/images/html.gif" /> </body> </html></pre> <pre>
In this case image request to http://www.musthaan.com/external/images/html.gif
</pre> <!DOCTYPE html> <html> <head> <title>HTML base Tag</title> <base href="http://www.musthaan.com" target="_blank"/> </head> <body> <a href="http://www.musthaan.com">musthaan </a> <a href="http://www.500px.com">500px</a> </body> </html></pre> <pre>
A common IE6 fix is using an IE conditional comment to include the end tag:
If you don’t care about the W3 Validator, or when you’re on HTML5 already, then you can just self-close it, every webbrowser supports it anyway:
Closing the tag also instantly fixes the insanity of IE6 on WinXP SP3 to request// <![CDATA[
resources with an relative URI in src in an infinite loop.
Another potential IE problem will manifest when you use a relative URI in the tag, such as or . This will fail in IE6/7/8. This is however not exactly browser’s fault; using relative URIs in the tag is namely at its own wrong. The HTML4 specification stated that it should be an absolute URI, thus starting with the http:// or https:// scheme. This has been dropped in HTML5 specification. So if you use HTML5 and target HTML5 compatible browsers only, then you should be all fine by using a relative URI in the tag.