<base> Tag in HTML 5
In this article I ma going to explain about <base> tag in HTML5
Definition
A Base tag provides a default (base) URL or relative links. It is usually used to set a default URL for all subsequent relative links. The <base> tag specifies the base URL/target for all relative URLs in a document. <base> tag must be placed inside <head> element. Implementation and working of <base> tag is same in HTML 4.01 and HTML5. There are no difference.
<base> tag doesn't have any event attribute. <base> tag must be first inside <head> element.
Browser Support by <base> tag
The <base> tag is supported in internet explorer, mozilla firefox, Google chrome, opera and safari browsers.
Attributes of <base>tag
Attributes |
Value |
Description |
href |
URL |
Specifies the base URL for all relative URLs in the page |
target |
_blank
_parent
_self
_top
framename |
Specifies the default target for all hyperlinks and forms in the page |
Lets take an example of <base> tag
<html>
<head>
<title>My first web page</title>
<base href="http://in.yahoo.com/" target="_blank" />
</head>
<body>
<h1>
<p>
<a href="http://in.yahoo.com/">Yahoo news</a> -
This link opens in a new window, even if it has no target="_blank" attribute. It
happens because the target attribute of the base element is set to "_blank".
</p>
<p>
<a href="http://fb.com/">Facebook</a> - This link opens
in a new window, even if it has no target="_blank" attribute. It happens because
the target attribute of the base element is set to "_blank".
</p>
</h1>
</body>
</html>
|
Output

Further Readings
You may also want to read these related articles :
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here