HTML <base> tag
Definition and Usage
The base element specifies a base URL for all the links in a page.
Differences Between HTML and XHTML
In HTML the <base> tag has no end tag.
In XHTML the <base> tag must be properly closed.
Tips and Notes
Note: The <base> tag must go inside the head element.
Example
Assume that the absolute address for an image is:
<img src="http://www.w3schools.com/images/smile.gif" /> |
Now we insert the <base> tag, which specifies a base URL for all of the links in a page, in the head section of a page:
<head> <base href="http://www.w3schools.com/images/" /> </head> |
When inserting images on the page in the example above, we just have to specify the relative address, and the browser will look for that file using the full URL, "http://www.w3schools.com/images/smile.gif":
<img src="smile.gif" /> |