Text Links

Contact Us or call 1-877-932-8228
Text Links

Text Links

The tag for a link is perhaps the least intuitive of all the HTML tags. It is <a> and it comes from the word "anchor." You will see why later in the lesson. By itself, the <a> tag does nothing. To create a link, it requires the href attribute, which takes as a value the path to the file to which to link. The syntax is as follows:

Syntax

<a href="path_to_file">Link Text</a>

For example:

<a href="bios/JohnLennon.html">John Lennon</a>

Note that, in HTML 4, <a> elements may not be direct children of the body element; however, that rule has been removed in HTML5 which allows inline tags as direct children of the body. This doesn't mean a link tag can't be in the body in HTML 4, but that it has to be the child of another element, say, a <p> tag.

In HTML5, this is allowed:

<body>
    <a href="http://www.webucator.com">Webucator</a>
</body>

Whereas the <a> element would have to be enclosed in another element in HTML 4, like this:

<body>
    <div>
        <a href="http://www.webucator.com">Webucator</a>
     </div>
</body>
Next