HTML and CSS Reference
In-Depth Information
In such cases, instead of including a
target
attribute for each
<a>
tag, you can use
another tag,
<base>
, to define a global target for all the links on a web page. The
<base>
tag is used as follows:
<
base target
=
“
window_name
”
>
If you include the
<base>
tag in the
<head>...</head>
block of a document, every
<a>
tag that doesn't have a
target
attribute will be directed to the window indicated by the
base
tag. For example, if you had included the tag
<base target=“yellow_page”>
in
the HTML source for
parent.html
, the three hyperlinks could have been written as fol-
lows:
<!DOCTYPE html>
<html>
<head>
<title>
Parent Window - Red
</title>
<style type=”text/css” media=”screen”>
body {
background-color: #ff9999;
17
}
</style>
<base target=”yellow_page”>
<!— add base target=”value” here —>
</head>
<body>
<h1>
Parent Window - Red
</h1>
<p><a href=”yellow.html” target=”yellow_page”>
Open
</a>
<!— no need to include a target —>
the Yellow Page in a new window.
</p>
<p><a href=”blue.html” target=”blue_page”>
Open
</a>
the Blue Page in a new
window.
</p>
<p><a href=”green.html” target=”yellow_page”>
Replace
</a>
<!— no need to include a target —>
the yellow page with the Green Page.
</p>
</body>
</html>
In this case,
yellow.html
and
green.html
load into the default window assigned by the
<base>
tag (
yellow_page
);
blue.html
overrides the default by defining its own target
window of
blue_page
.
You also can override the window assigned with the
<base>
tag by using one of two
special window names. If you use
target=“_blank”
in a hyperlink, it opens a new
browser window that doesn't have a name associated with it. Alternatively, if you
use
target=“_self”
, the current window is used rather than the one defined by the
<base>
tag.

