Working with Links: Anchor Tag

Web pages are linked to one another through Hypertext Links. Section of text or image in the HTML document can be linked to an external document or to a specific place within the same document. The text or image that provides such linkage is known as Hypertext.

HTML provides <A> Anchor Tag to create links. The format of using anchor tag is:

<A HREF="URL">Make Me The Link</A>

The HREF (Hyper Link Reference) is a mandatory attribute used to refer the URL of the resource. URL (Uniform Resource Locator) is an address tells the browser about the file to link to.

The link text appears underlined and in a color different from any other text in the document to distinguish a link from normal text. The mouse pointer changes into a hand like symbol when taken over the hyperlink.

Linking to specific place within the same document

Sometimes, it is required to jump different sections in the same document. For this, it needs two steps:

  1. Identify section with a name
  2. Use jumps to the location using the name used

The syntax is:

<A HREF="#section_name">Link to another section</A>

This link text jumps to the section named with HREF on click. The # symbol before the section name is must.

<A NAME="section_name">Beginning of the section</A>

The NAME attribute is used to identify a section with a name. It is a unique identifier within the document for the anchor. You can also jump to a specific section of different document specifying the path on HREF attribute.