Go to main content
Bypass navigation bar HTML Reference HTML Tags HTML Tutorials
Bypass language selection
Bypass location bar

Location: Home > HTML Reference > HTML Tags > HTML base tag

Bypass main content

HTML base tag

Note: If you don't know what an element/tag is and/or how you must use it we recommend you read our HTML tags and attributes tutorial, which you can find in our HTML tutorials section.

Bypass main content

Description

The HTML base element sets the base URI that will act as starting point for all relative URIs present in the document. When absent, the base URI is the URI of the folder containing the document.

This element must be inserted somewhere in the head of the document (HTML head element).

Examples

Let's suppose we need to insert a large number of images in this document (http://www.htmlquick.com/reference/tags/base.html), that are located in the images folder (http://www.htmlquick.com/images/). Then we should have every image inserted with an URI like "../../images/image.png".

The HTML base element can help shortening these URIs (that can be many) by setting a base URI to resolve the images' URIs.

<html>
<head>
<title>HTML base tag</title>
<base href="http://www.htmlquick.com/images/" target="_blank">
</head>
<body>
<img src="image1.png" />
<img src="image2.png" />
<img src="image3.png" />
</body>
</html>

Note, that this statement will affect all URIs in the document, and not just the images' URIs.

Attributes

href (uri)

The "href" attribute specifies the base URI that will act as starting point to resolve all URIs in the document.

<base href="http://www.modernsociety.com/docs/drugs/">

target (frame-target)

Specifies the name of the frame where all linked resources in the document will be opened by default. Refer to the frame-target type definition for further information.

<base href="http://www.modernsociety.com/docs/drugs/" target="_blank">

Events

This element doesn't support events.

See a complete list and information about events in HTML

Diseño y desarrollo: Latitud29.com

Links and logos|Contact|Beyond HTML|Tools and resources|Sitemap|Webmaster|Donate