<base>

PURPOSE: The BASE tag is a way to set the hyperlinks in a page to use a base url as a target location. It works with frames and other pages.

The BASE element must appear in the HEAD section of an HTML document, before any element that refers to the external source. The path information specified by the BASE element only affects links in the document where the element appears. It has two attributes, href= and target=.

Essentially, in the example below, including this element means that a relative link in your document is interpreted as http://www.southerntwilight.com/tutorials/ no matter where the document is. In the absence of a BASE element the browser uses the URL of your document to figure out relative links. It just saves you from typing the complete url to the link.

It can be very useful if you need to link to a page on another server, or if a page is accessed from multiple domain names. This way you do not need to update all your links, just the <base> of the document.

The attribute target= can be set to any of the following:
_blank to open in a new window
_self to open in the current frame
_parent to open in the frameset parent
_top to open in the whole browser window with no frames

Don't forget the underscore _ character, it must be included, and the letters must all be lower case.

Below is a basic html document. The referenced html tag is in RED. All tags must have a start and a end tag. Most end tags have a / before the tags name, however there are a few that are done differently. The tags that end differently will be noted and highlighted. The order of the start and end tags is also very important to proper display of your page in a web browser.


<html>
<head>
<base href="http://www.southerntwilight.com/tutorials/">
<title>The Base Tag</title>
</head>
<body>
<p>
<a href="tutorial.html">The HTML Tutorials</a>
</p>
</body>
</html>


This example code would work with frames.

Your Frameset:

<html>
<head>
<title>A Frame Example:</title>
</head>
<framset rows="20%, *">
<frame src="something.html" name="top">
<frame src="main.html" name="mainframe">
</frameset>
</html>

Your Navigation Frame Page:

<html>
<head>
<base target="mainframe">
<title>The Base Tag</title>
</head>
<body>
<p>
<a href="page1.html">Page 1</a>
<a href="page2.html">Page 2</a>
<a href="page3.html">Page 3</a>
</p>
</body>
</html>


© Copyright 2001,2002 Southern Twilight    All rights reserved.

Back To HTML Examples