The <a> Tag and the href Attribute
HTML markup uses the
<a> (the link or anchor) tag to
create a link to another document.
An link can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc.
The syntax of creating a link is as follows:
<a href="web_address_of_the_page_or_image_etc">Text to be displayed</a>
Link markup should always be placed inside a BLOCK ELEMENT
such as between
Links inside documents
You can create links
inside long documents to allow people to
move straight to a particular sub-section.
To create such links, first place a reference anchor at the point you want people to jump to your markup and then place a link to allow people to jump to that point.
For example, the following markup is placed at the top of this page:
And this link will allow you to jump straight to the top of the page by using:
<a href="#top">this link</a>
Right click on this page and select View Page Source to see if you can locate these particular pieces of markup.
Let's say you want to enter an email address, [email protected], and make it clickable.
The syntax for this would be:
The URI inside the
<a> tag is is the email address you want to link to.
The text surrounded by the
</a> is the link text that
you want displayed on your page.
So if Joe Smith's email address is [email protected], you could use:
<a href="mailto:email@example.com">Joe Smith</a>