Link in HTML

Link in HTML


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 or Hotspot. HTML provides <A>Anchor Tag to create links. The format of using anchor tag is as follows:

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

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. It identifies file locations (Addresses) on the web or on the local hard drive. These addresses can be those of HTML documents or elements such as images, scripts, applets and other files. It 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’.

Name: to define the name of link by which we can bookmark the location and can jump to this location.

Linking a text to a web site / an external document

Example:

<A HREF =http://www.programmingtrick.com target= “_blank”>Link to Website of Infomax Academy</A>

In the above example the link text “Links to Home page of infomax academy” would appear underlined and in a color different from any 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 web site

An image can be linked to a web site or HTML document.

<A HREF ="http://www.programmingtrick.com"><IMG SRC=”infomax_logo.png” ></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 or second; use jumps to the location using the name used.

The syntax is:

<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.

<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">

Same folder, but different document: <AHREF="document.html#section_name">

Different folder, different document:

<A HREF="folder/document.html#section_name">

A different server:

<A HREF="http://www.programmingtrick.com/foldername/document.html#section_name>

Qus. 1 : Hypertext is a:

  1. Text with heavy text jargons
  2. Text more than 1000 words
  3. Text which contains link to other texts
  4. None of the above
Qus. 2 : A set of navigation links is defined using tag:

  1. <a>
  2. <nav>
  3. <href>
  4. None of the Above

Programs

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad