Little Web Hut

HTML 4.01 and XHTML 1.0 Reference: <base> Tag

HTML <base> Tag - Base URL
Syntax HTML syntax - This element does not require a closing tag.
<base>

XHTML syntax - This element is opened and closed, within a single tag, by adding a space followed by a forward slash at the end of the tag.
<base />
Usage The <base> tag is used to specify a base URL for a web page document. This allows other URLs in the document to use relative addresses that are relative to the base URL. The <base> tag is placed in the head section of the document before any references to it. The href attribute holds the base URL.

HTML <base> tag example.
<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <base href="http://www.littlewebhut.com">
</head>
Test It HTML Style

XHTML <base> tag example.
<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <base href="http://www.littlewebhut.com" />
</head>
Test It XHTML Style

Content Model The <base> element cannot contain any tags.

Red attributes have been deprecated
<base> Tag Attribute Summary
Required Tag Specific Core Focus Events Language
href target id1      
Notes: 1. XHTML only.

Red attributes have been deprecated
<base> Tag Attributes
Attribute Description
hrefThe href attribute holds the base URL for the document.

HTML <base> example using the href attribute.
<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <base href="http://www.littlewebhut.com">
</head>
Test It HTML Style

XHTML <base> example using the href attribute.
<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <base href="http://www.littlewebhut.com" />
</head>
Test It XHTML Style


Note: This is a required attribute.
targetThe target attribute specifies a default target window for the links within the current document.

HTML <base> example using the target attribute to open all links in a new tab or window.
<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <base href="http://www.littlewebhut.com" target="_blank">
</head>
Test It HTML Style

XHTML <base> example using the target attribute to open all links in a new tab or window.
<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <base href="http://www.littlewebhut.com" target="_blank" />
</head>
Test It XHTML Style

HTML <base> example that will open all links in an iframe pointed to by the target attribute.
<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <base href="http://www.littlewebhut.com" target="sample1">
</head>

<body>
<p>
 Open web page in an iframe by <a href="/html/">clicking here.</a>
 <iframe id="sample1" name="sample1" height="50%" width="100%" title="sample"></iframe>
</p>
</body>
Test It HTML Style

XHTML <base> example that will open all links in an iframe pointed to by the target attribute.
<head>
 <title>HTML Test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <base href="http://www.littlewebhut.com" target="sample1" />
</head>

<body>
<p>
 Open web page in an iframe by <a href="/html/">clicking here.</a>
 <iframe id="sample1" name="sample1" height="50%" width="100%" title="sample"></iframe>
</p>
</body>
Test It XHTML Style


Note: This attribute has been deprecated.
idThe id attribute assigns a unique name to a tag. This allows style sheets or scripts to reference the tag. See id Example

Note: XHTML only.

HTML <base> Tag Examples
Test It HTML StyleTest It HTML Style<base> tag example.
Test It HTML StyleTest It HTML Style<base> example using the target attribute to open all links in a new tab or window.
Test It HTML StyleTest It HTML Style<base> example that will open all links in an iframe pointed to by the target attribute.