HTML base

From Htmlpedia
Jump to: navigation, search

HTML Element Base

Definition and usage

The <base> element defines the base URL of a document and/or the default target attribute (in a transitional doctype). "Base URL" refers to whatever would precede a relative URL. It may only be used within the <head> section of a document.


Example

<base href="http://www.example.com/">

Result

A relative hyperlink such as:

<a href="products/htmlpedia.htm">HTMLPedia product information</a>

Would link to http://www.example.com/products/htmlpedia.htm, as what precedes it was defined in the <base> tag.

Attributes

href
Defines what will precede any relative hyper-text references, be they hyper-links (<a href="">, or images (<img src="" />).
target
Only available in transitional doctypes. Defines the default target attribute for hyper-links, but can be over-ridden on a per-hyperlink basis.