HTML Links

HTML links are hyperlinks.

A hyperlink is a text or an image you can click on, and jump to another document.

HTML Links - Syntax

In HTML, links are defined with the <a> tag:

<a href="url">link text</a>
                  

Example:

<a href="http://coderdojomallow.com">Visit CoderDojo Mallow!</a>
                  
Try it Yourself

The href attribute specifies the destination address (http://www.w3schools.com/html/)

The link text is the visible part (Visit our HTML tutorial).

Clicking on the link text, will send you to the specified address.

Local Links

The example above used an absolute URL (A full web address).

A local link (link to the same web site) is specified with a relative URL (without http://www....).

<a href="about.html">About Us</a>
                  

HTML Links - The target Attribute

The target attribute specifies where to open the linked document.

This example will open the linked document in a new browser window or in a new tab:

<a href="http://coderdojomallow.com" target="_blank">Visit CoderDojo Mallow!</a>
                  
Try it Yourself

HTML Links - Image as Link

It is common to use images as links:

<a href="http://coderdojomallow.com" target="_blank">
  CoderDojo Mallow
</a>
                  
Try it Yourself