Links are snippets of code that give web browsers directions to get from one page to another on the Web. What makes links powerful is that the distance covered by those directions doesn’t matter. A link can lead to another page on the same site just as easily as it can lead to a page on a web server halfway around the globe.
Behind the scenes, a simple HTML tag called the anchor (<a>) tag makes each and every link work. Links come in three flavors: absolute, document-relative, and root-relative. See Link Types in Action for some examples of each link type in practice.
When people want to mail you a letter, they ask for your address. Suppose it’s 123 Main St., Smithville, NY 12001, USA. No matter where in the country your friends are, if they write 123 Main St., Smithville, NY 12001, USA on an envelope and mail it, their letters will get to you. That’s because your address is unique—just like an absolute link.
Similarly, every web page has a unique address, called a URL (most people pronounce it “you are el”), or Uniform Resource Locator. If you open a web browser and type http://www.sawmac.com/dwcs5/index.html into the address bar, the home page for this book opens.
This URL is an absolute link—it’s the complete, unique address for a single page. Absolute links always begin with http://, and they always lead to the same page, no matter where the link appears—an absolute link in a web page can call up another page within the same site or a page on another ...