The what? Base, you know. You never heard of it? In a quest for something new to write about I found this neat little meta tag that can make your coding a little easier if you like to work off line first. It’s also handy if you like to use a basic starting template when designing your sites. Here is a sample of it being used from this Home Builders site.
<base href=”http://www.homebuildersaustralia.com.au/” />
You keep it in the header section, before </head>, and it’s typically kept right by the title tag.
So you may be asking what is the point of it? The easiest way to explain it is to think of it as a global variable. It’s also that much less you have to type when pointing to documents throughout your site. Tired of typing the full url to a simple image? If you use the base tag, you can at least skip the domain name now. It’s now a given.
Now if we use a couple more examples from the Home Builders site, you may notice the base tags are a little different.
The Painters Brisbane page reflects
<base href=”http://www.homebuildersaustralia.com.au/painters-brisbane.html” />
and the Carpenters Brisbane page reflects
http://www.homebuildersaustralia.com.au/carpenters-brisbane.html
Why not just show http://www.homebuildersaustralia.com.au/ ? Well, you could. What is simply happening is the site owners is most likely using an automated method to create the base url. The base url should equal the url of the exisiting page. When images or links within the page access the base tag to make the address correct, it strips off the the file name, and only uses the directory.
Probably the biggest advantage to this little tag is the moving of files. If you were to restructure a site, or upload a site to a server, it’s simply a one line edit, the base tag, to tell all the other little links and images where to look.
- March 9, 2009
- Posted by Robert Campbell at 6:08 pm
- Add comments
- Code, Usability & Design
- base, base tag, meta, tag
