XHTML Reference: base

The XHTML WYSIWYG Editor For Desktop & Web Applications

base

Definition

To resolve relative URLs, Web browsers will use the base URL from where the Web page was downloaded. In some circumstances, it is necessary to instruct the Web browser to use a different base URL, in which case the base element is used.

Example

In the following example, regardless of where the Web page was downloaded from, the CSS file will be downloaded from http://xstandard.com/screen.css and the image will be downloaded from http://xstandard.com/images/logo.gif.

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <base href="http://xstandard.com" />
  5. <style type="text/css">@import url('screen.css');</style>
  6. </head>
  7. <body>
  8. <h1><img src="images/logo.gif" alt="XStandard" /></h1>
  9. </body>
  10. </html>

Best practice

If the base element is to be used, it should be defined before any relative URL is used.

Attributes

Basic

href
(URI) Specifies an absolute URL that acts as the base URL for resolving relative URLs. This attribute is required.

Contains

  • Nothing