web design basics: tools, tips, & tricks
 
 

HTML › links

The whole idea behind hypertext is to link pages and images together in a non-linear manner. So it makes sense that I show you how to establish those links, don’t you think? Let’s get moving!

•••  internal links

A simple textual link to a page internal to your site looks like this within your HTML code:

<a href="samplelink.htm">Click here.</a>

This code will render like this in your browser:

Click here.

The “a” portion of this tag stands for “anchor;” “href” is an attribute of this anchor tag and stands for hypertext reference. The address for that hypertext reference is enclosed in quotation marks and indicates, in this case, that the browser should look for a document called “samplelink.htm” within the same directory as this document. Notice that an anchor tag requires a closing tag; what is within those opening and closing tags is what will show up in your browser window to direct your user to a new page.

•••  external links

If you want to link to a page external to your website, to a page created by someone else, you need to include the entire URL (or HTTP address) in the address portion of the anchor tag. Here’s an example:

<a href="http://www.htmlgoodies.com" target="_blank">Click here to go outside this website.</a>

This code will render like this in your browser (and will send you to HTMLGoodies.com):

Click here to go outside this website.

If you clicked on the link above, you will note that HTMLGoodies.com opened up in a new browser window. That is because I added the target="_blank" attribute to the anchor tag. This attribute — you guessed it — tells the browser to open up the referenced page in a blank window.

tip

When linking to an external page, it’s a good idea to force the browser to open up a new window. Your user then knows he or she is on a different site.

•••  e-mail links

You can add an e-mail link to your pages, too. The code looks like this:

<a href="mailto:oharaspub@comcast.net">E-mail me!</a>

This code will render like this in your browser:

E-mail me!

If you were paying attention when you moused over the “E-mail me!” link above, you noticed that a small box with the words "click here to send me a message" appeared on your screen. This text label (similar to an <alt> tag used with images — we’ll get to that) was accomplished with the following title attribute:

<a href="mailto:oharaspub@comcast.net" title="click here to send me a message">E-mail me!</a>

It is not required that you include add a title attribute to your links. It can, however, be a useful tool, another way to make your site user-friendly.

trick

The default color for a link is blue; a visited link is purple. If you’re not partial to blue and purple, you can change this color scheme with a style sheet.

 

 

the starting point

content

navigation

» HTML

   › saving files

   › basics

   › links

   › tables

CSS

color

images

 

project

home «

 

The views and opinions expressed in this page are strictly those of the page author.
The contents of this page have not been reviewed or approved by the University of Minnesota.