Improve Site Performance Increase Site Traffic Monitor Site Uptime Webmaster Resources NetMechanic Home Looking For Help? Partner Programs Privacy Policy Contact Us Press Room
NetMechanic Home LOGIN | HELP | ABOUT US | PRODUCTS | SITE MAP
NetMechanic Menu
Over 52 Million Web Pages Tested!     
 
Story on base tag.
base tag story search bar.
Search for:


Your Email:

I would like to receive my newsletter in:
HTML format
Text format


Tips on managing links.
Volume 8 (2005)
   September
   June
   April
   March
   January

Volume 7 (2004)
   November
   September
   July
   June
   May
   April
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 6 (2003)
   December
   November (Part 2)
   November
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 5 (2002)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 4 (2001)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 3 (2000)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June
   May
   April
   March
   February
   January

Volume 2 (1999)
   December
   November
   October
   September
   July
   June
   May
   April
   March
   February
   January

Volume 1 (1998)
   December
   November
   October
   September

 

Beginner Tip:
Manage Your Links With BASE

by Larisa Thomason,
Senior Web Analyst,
NetMechanic, Inc.

  
December 2001
Vol. 4, No. 23
 • Promotion Tip
 • JavaScript Tip
 • Beginner Tip
  

One line of code inserted in your document's HEAD section can help you manage your links more efficiently. If your page uses frames or has a lot of external links, consider using the BASE element. It helps you manage relative addresses, code, and maintain your site with less time and effort.

BASE Basic Syntax

The BASE element is an optional addition to your HTML document's HEAD section. It can contain just two attributes and either one can be used alone:
  • HREF: Specifies the base URL for the document. The URL specified should always be a complete address like: http://www.netmechanic.com.

  • TARGET: Identifies the default window that will open when your visitor clicks on any links on your Web page.

A sample BASE element might look like this:

<HEAD>
<BASE HREF="http://www.netmechanic.com/"
    TARGET="_blank">
</HEAD>

This code tells the browser that the base address for the Web page is netmechanic.com and instructs it to open all links in a new browser window.

Control Your Frames

If your site uses frames, you should already be quite familiar with the TARGET attribute. When a visitor clicks on a link on the framed site, TARGET tells the browser which frame to place the new page in.

If you include this code on your page -

<a href="http://www.netmechanic.com/" 
    target="_main">


you're telling the browser to open NetMechanic's home page in the frame titled "main." Note: anybody can load your page into a frame on their site. Avoid this by including JavaScript code to keep your page out of someone else's frame.

It's not much trouble to type the target attribute for a single link, but suppose you had 20 links on that page and wanted them all to load inside a certain frame? Instead of typing target="_main" 20 times, type it once with the BASE element:

<BASE TARGET="_main">

It even works if you have 20 links that need to load in the "main" frame and just one that goes to "contents" (or whatever name you've chosen). Just include the TARGET attribute inside that particular link's HREF tag and it will override the TARGET specified in the BASE element.

Manage External Links

You can use this same technique to manage links on a page that isn't in frames. A lot of sites have a specific page of links to related sites. You generally want these links to open a new browser window so that you don't losing your site visitors.

But again, it gets old adding the TARGET attribute to every link on the page, so use the BASE element:

<BASE TARGET="_blank">

Every link on the page will open a new browser window. Again, you can override the default target by including a TARGET attribute inside the individual HREF tag.

Manage Relative URLs

When you set a base URL for your document, then all relative links in the document are derived from this base URL. In our example above, we set the base URL to equal http://www.netmechanic.com/news/. Then, inside the BODY section, we could include images and internal hyperlinks by using just the relative address.

Now of course, you can do this without setting the BASE attribute at all! Most browsers will resolve relative URLs without any trouble, BUT they assume the current page is the base URL and resolve relative addresses according to its position.

That can get complicated if you have a large, multi-level site because the relative address sometimes isn't so obvious. Suppose you were using a PERL script located in the cgi-bin directory to generate an HTML page. Unless you tell the browser otherwise, it will resolve all the links relative to the cgi-bin, not the top-level directory.

Managing the link addresses can quickly get confusing in this situation because most people's tendency is to think of links relative to the home page or at least the top-level pages. While you aren't required to use the BASE element, it can often make debugging and maintenance easier.

Keep Links Updated

The TARGET attribute is a very useful and versatile way to control links on your page. You can also use it to assign specific names to new browser windows. That lets you send all news links to a window called "news" and all shopping links to a window called "shopping," etc.

It takes a lot of time to manage links on a large site - and even longer to test and maintain them regularly. Visitors don't like broken links, but who has the time to check every link on a daily - or even weekly - basis? Not most busy webmasters! They would rather spend time updating their sites with new content and products.

If you too have better things to do than click on link after link after link, use the Link Check tool that comes with HTML Toolbox. It tests each link on your site and alerts you to broken ones. Toolbox will also scan your HTML code and alert you to errors or browser-specific tags that might break your pages.

The BASE element helps you code your links more quickly and maintain them with less effort. Use it with Toolbox's Link Check tool and you'll find that managing links is a snap.



Rate This Tip:
Not Useful Useful Very Useful   
 
NetMechanic Tools
HTML Toolbox
Browser Photo
Server Check
Search Engine Starter
Search Engine Tools
GIFBot
Newsletter
HTML Tutorial and Tips
Search Engine Tutorial
Accessibility Information
Browser Problem Tutorial

Company Info
Products
About Us
Contact
Advertise
Link To Us
Jobs
Privacy Policy
Partner Programs
Press Room
RSS Feed
Support
 



Powered by Overture!

 
     
 
   
 
     


Keynote Home
Copyright © 1996-2007,
Keynote NetMechanic
All rights reserved.