Creating hyperlinks on web pages

Creating hyperlinks on web pages cover image
  1. Home
  2. HTML
  3. Creating hyperlinks on web pages

HTML documents contain certain ‘hot spots’. These hot spots provide anchors that link to other documents/files on the Internet. The stupendous growth of the Internet and the WWW is attributed to these tags. It’s hard to imagine a network without links and interlinks.

Lets look at this tag in detail.

<A HREF="//www.webdevelopersnotes.com">This will 
take you to Webdevelopersnotes.com's main page</A>

is displayed as This will take you to Webdevelopersnotes.com’s main page.

Another attribute is TITLE, through which you can provide some explanatory text for that link. Netscape ignores this attribute. To see this attribute in action, place your mouse over the link.

Homepage

Its code is:

<A HREF="http://www.webdevelopersnotes.com"
TITLE="This takes you to webdevelopersnotes.com's mainpage"
>Homepage</A>

Linking in the same document

So far we have discussed only inter-document linking. What if you want to make the visitor jump to different sections of the SAME page? We employ the <A> tag in this case too, but its format changes slightly. Instead of a URL in the HREF attribute, we use names.

First, an anchor is set at the desired place in the document using the NAME attribute. In this case I put the following code at the top of the page.

<A NAME="top"></A>

The value of NAME attribute can be anything you want. Also note, that it is not necessary to enclose any text or other HTML element if the anchor tag is used in this manner.

After setting an anchor with its NAME attribute we employ another set of <A> to make a link that points to it:

<A HREF="#top" CLASS="text">Click here to go to the top</A>.

On clicking this link, you will be taken to the top of the page where I have put the anchor. The HREF attribute takes the value of the NAME attribute mentioned before as its value; the name is prefixed with a # symbol.

HTML