base tag (XHTML 1.1)

document base URI

Topics

The base tag allows you to define a root path for your pages, which will be used when resolving relative paths to images, stylesheets, links etc. For instance, you may reference an image like this:

<img src="images/icons/happy.gif" />

With no base path defined, the browser will request the image from a directory called images, in the same folder as the document being requested. But if that document is already in another subfolder, the path will not be valid. You can define the root path with the base tag and the href attribute, which is required, like this:

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

Now all your paths will be relative to this path.

Remember that the base path has to be defined within the head tag section of your website, preferably as the first child tag, to make sure that it has an impact on CSS references etc.

Attributes

Attribute Deprecated Required Description
class  space-separated list of classes 
dir  direction for weak/neutral text 
href  URI that acts as base URI 
id  document-wide unique id 
lang  language code 
style  associated style info 
target  render in this frame 
title  advisory title 

Events

Event Description
onclicka pointer button was clicked 
ondblclicka pointer button was double clicked 
onkeydowna key was pressed down 
onkeypressa key was pressed and released 
onkeyupa key was released 
onmousedowna pointer button was pressed down 
onmousemovea pointer was moved within 
onmouseouta pointer was moved away 
onmouseovera pointer was moved onto 
onmouseupa pointer button was released 



© htmlpedia.net 2008 - 2012