Perhaps the most important aspect of HTML is the ability to link from one document to another. This is the basic concept underlying the web and without this functionality the World Wide Web would not exist.
Link syntax
Creating links is relatively straightforward. To create a link, you’ll use the anchor element (<a>) to wrap the content you wish to convert to a link. Attributes inside the anchor tag tell the browser where the page is linking to.
<a href=”syntax.htm” title=”learn more about syntax”>HTML syntax</a>
The href attribute tells the browser how to resolve the link. The optional title attribute provides a description and helps make the link more accessible.
Link types
There are three basic types of link: absolute, site-root relative, and document relative.
Absolute links
These links contain the entire URL including the protocol, usually for external links.
<a href=”http://www.google.com” title=”Google”>google.com</a>
Document relative links
These are used to navigate internally based on the current page's location in the directory structure. To move out of a directory, you use “../”.
<a href=”../contact.htm” title=”our contact page”>Contact us</a>
Site-Root Relative Links
All links are preceded by a forward slash (/) that refers to the root directory, regardless of where the current page is located.
<a href=”/resources/contact.htm” title=”our contact page”>Contact us</a>
Fragment identifiers
Fragment identifiers allow you to link to a specific location within a page using an element's ID attribute and a hash symbol (#).
<a href=”#camp”>Learn more about camping</a>