More LinksS2C Home « More Links

In Lesson 8 of the Basic HTML Tutorials we showed how to utilize links and hyperlinks to navigate our way around. In this lesson we firstly explain what URLs are all about and then we show you how to set a base URL for the links on your current page. All links within the page will be relative to the base location specified. This tag is only allowed within the <head> </head> element.

The <base /> Tag

The <base /> tag defines a base URL for the links on a page and is self closing.

An Explanation of URLs

Ok, before we go into the practicals for this lesson lets take a bit of time to explain Uniform Resource Locators (URLs) and what they're all about.

Base URL

The base url normally consists of the protocol being used, which in our case will be the HTTP protocol and the server name directory, which for us will be

This will give us a base url of

Relative URL

The common use of a relative URL is by omitting the protocol and server name, as documents generally reside on the same server. So this would be directoryName/fileName.extension.

For example the relative url images/chickenpiesmall.jpg

Absolute URL

An absolute url is the complete address of the resource.

For example the absolute url

Viewing the Tag

Lets take a look at the base tag and it's usages.

Open the file with Notepad we created and tested in Lesson: 4 Definition Lists

You saved the file to your computer in the C:\_HTMLIntermediate folder as lesson_4_webpage.html

Copy and paste the following code into the reopened file, overwriting the existing contents.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  
<!-- Using The base URL -->
<html xmlns="">
  HTML Tutorials - Intermediate HTML Lesson 5 - More About Links
  <base  href="" />
<h3>List Of Images</h3>
 <dt>Pie Pictures</dt>
    <dd><img src="images/chickenpiesmall.jpg"
             alt="Chicken Pie" width="75" height="50" /> </dd>
    <dd><img src="images/fishpiesmall.jpg"
             alt="Fish Pie" width="75" height="50" /> </dd>
    <dd><img src="images/shepherdspiesmall.jpg"
             alt="Shepherds Pie" width="75" height="50" /> </dd>

Save the file in the C:\_HTMLIntermediate folder as lesson_5_webpage.html and close the Notepad.

save more links

Viewing Our Changed File

From the C:\_HTMLIntermediate folder, double click on the saved file and it will appear in your default web browser and look something like the following image.

save more links

Reviewing Our Changes

The <base /> tag allows us to set a base URL location in our HTML documents to let us use relative URLs to point to addresses in our web pages.

Lesson 5 Complete

Modify the HTML to point to files on your own computer to get a real feel of how the base and relative URLs hang together.

Related Tutorials

HTML4 Basic Tutorials - Lesson 8 - Links

What's Next?

We show how to organize our display data into tables.

HTML4 Reference

The <base /> base URL location tag

go to home page Homepage go to top of page Top