LINKS IN HTML - Anchor Tag


Insert Links in HTML : ANCHOR TAG <A>

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 linking is known as Hypertext. HTML provides <A> Anchor Tag to create links. The format of using anchor tag is given below:

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

HREF (Hyper Link Reference) is a mandatory attribute used to refer the URL of the resource. The URL (Uniform Resource Locator), is an address which tells the browser about the file to link to. It identifies file locations (Addresses) on the web or on the local hard drive. These addresses can be HTML documents or elements such as images, scripts, applets and other files. The URL is always enclosed in quotes. 

Attribute of <a> tag:

Target: It is used to specify the location of page where linked data will be open/display. The possible values are: ‘new’, ‘_blank’, ‘self’, ‘parent’. Default target is set as ‘self’.

Linking a text to a website / an external document-

Example:

<A HREF ="https://www.itcomputerguruji.com" target= “_blank”>Link to Website of IT Computer Guruji </A>

In the above example the link text “Links to Home page of IT Computer Guruji” would appear underlined and in a different color from other text in the document to distinguish a link from normal text. Also you would find that the mouse pointer changes into a hand like symbol when taken over the hyperlink.

Linking an image to website-

An image can be linked to a website or HTML document.

<A HREF ="https://www.itcomputerguruji.com"><IMG SRC=”logo.GIF” BORDER= “3”></A>

Linking (jumping) to a specific place within the same document-

Sometimes, it is required to jump different sections in the same document. For this it needs two steps, first: identify section with a name and second: use jumps to the location using the name used.

The syntax is:

1.  <A HREF="#section_name"> link to another section of the same document </A>

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

2.  <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. One can also jump to a specific section of different document specifying the path on HREF attribute.

Example:

Within the same document: <A HREF="#section_name"> </A>

Same folder, but different document: <A HREF="document.html#section_name"> </A>

Post a Comment

0 Comments