XHTML » Tags » base

Syntax:
<base />

The base tag is used to define the base URL for the HTML document. This allows the use of relative URL addresses elsewhere in the document.

Also, when a browser arrives from another site to your site via a link, you can use the target attribute of this tag to ensure that your site does not appear inside a frame or window of the previous site. In other words, your site will always appear as the top window.
 
The base tag must be placed between the opening and closing head tags.
 
This is a self-closing tag. The blank space before the slash (/) is recommended for maximum browser compatibilty.
 

Examples

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML base Tag Example</title>
<base href="http://www.devguru.com/">
</head>
<body>
<a href="/technologies/HTML/quikref/html_index.html">HTML Index</a>
</body>
</html>
Explanation:

In this example, the link in the body resolves to: http://www.devguru.com/technologies/HTML/quikref/html_index.html

Language(s): XHTML
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML base Tag Example</title>
<base target="_top">
</head>
<body>
...
</body>
</html>
Explanation:

This code directs that your site always appears as the top window.

Language(s): XHTML

See Also: