Thursday, July 22, 2010

The <base> element

base is an empty element, which means that it does not have any content. However it does have attributes. It is only found in the head element. This element must appear before any element that contains URLs.



This is a required attribute whose value is a URL which is added on to all relative URLs in the document. The url specified must end with a forward slash. Note that the base url specified affects all relative URLs - those contained in <link>, <form>, <a>, <img>, <iframe>, etc.

Example 1: <base href="" />

Example: 2 <base href="/pages/" />


All links in the page (<a> elements) load in a new window with the internal name specified in target.

Example: <base href= "/images/" target="_blank" />

Note that the default target can be overridden by the target attribute in an a tag.

No comments: