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.

Attributes

href

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="http://destination-code.blogspot.com/" />

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

target

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: