Links and images are the most popular things on web pages. They are easy to add (just two basic HTML tags) and they bring excitement to your plain text pages. Here you will learn about the
A (anchor) tag.
A link is called an anchor in HTML, and so the tag to represent it is the
A tag. When you add a link, you must point to the web page address that you want your users to go to when they click the link. You specify this with the
href attribute stands for “hypertext reference” and it's value is the URL where you want your link to go to.
For example, to create a text link, you write:
<a href="URL of the web page to go to">Text that will be the link</a>
So to link to the About.com Web Design/HTML home page, you write:
<a href="http://webdesign.about.com">About Web Design and HTML</a>
You can link nearly anything in your HTML page including images. Simply surround the item you want to be a link with the
<a href=""> and
</a> tags. You can also create placeholder links by leaving out the
href attribute. HTML5 makes it valid to link block-level elements like paragraphs and
Some Things to Remember When Adding Links
- The final
</a>tag is required. If you forget to include it, everything following that link will also be linked, until another link closes the tag.
- Most of the time, it's best to link single images and short spans of text, rather than large blocks of text. Links can add colors and underline styles to your page that can be hard to read.
- Make sure to check your links so that they don't go bad. Link Rot can make both users and search engines consider your site invalid. Use a link checker to verify the links on your pages.
Other Interesting Types of Links
A element creates a standard link to another document, but there are other types of links that you might be interested in:
- Internal Links or Anchors—These are links to somewhere within a web page, not necessarily the top.
- Image Maps—Image maps let to create links on images that are mapped to specific areas of the image. These can be used for games or creative navigation. You often see them with maps where areas on the map are clickable.
LINKElement—This element is used to relate other documents and pages to the current one. It won't create a clickable area on your web page, but it's useful to understand.