Add links to your website

Links are the key feature of the web. With links you can refer to other sites and the user is able to "jump" from one website to the next.

But how to add them to your site? It's easy. You can use the a tag:


<a href="test2.htm">link text</a>

This link is referring to the HTML Site test.htm which is a second site from you.

When you want to link to other pages, you can also use the complete url of the page. A link to our website for example would look like this:

<a href="">My favorite it site</a>

These simple links have one drawback. Pages that are clicked, will be opened in the same windows. So when you add a link to an external website, the user will leave your website.


To prevent this, you can add a target attribute to the link tag.

<a href="" target="somewhere">
   My favorite it site

The target defined the name of the target window, when you refer to a new windows, by convention the following should be used:

<a href="" target="_new"> 
   My favorite it site

Images as Link

For sure you can nest HTML tags in many combinatios. A quite common one is, to use an image as a link.

To do this you can just wrap your image tag with an a tag:

<a href="" target="_new">
   <img src="myimage.gif"/>

By now we've learned how to create links from page to page. But what if you want to create a link to a specific paragaph, video or image of a page?

HTML Anchor links

When you want to link to a specific part of a page, you should use an anchor link.

But before you can link to an anchor, you need to define this anchor. The anchor can be defined with the following HTML tag:


<a name="myanchor">Anchor content</a>

You can refer to the anchor, with the following tag:


<a href="#myanchor">link text</a>

or from another site you can refer with the following link content:


<a href="page.htm#myanchor">link text</a>

Wow! You've learned a lot! You are now able to create a website with links and know how to proper format the content of the page.


Websites get more spirited, when they are interative and involve the user. With forms you can involve the user and create interative elements on your website. Also for webbased applications form are very important.


On the following page, we will create a simple form to send a mail, to get used to the HTML form elements.