A link in HTML is technically called Hyperlink. Hyperlinks are the links to navigate to another page or section in a website. It can be a text (a word or a phrase) or an image. Text hyperlinks are more common than image hyperlinks.
When clicked, a hyperlink takes the user from the current page or section to a different page or section. This different page or section, for which the link is created, is called the target of hyperlink.
The tag used for creating a hyperlink is <a>. It is a container tag. ‘href’ is the principal attribute used with the tag <a>. Here <a> stands for ANCHOR and ‘href’ stands for HYPERTEXT REFERENCE.
Types of hyperlinks: Depending upon the target, hyperlinks are of following two types:
These links are used to connect two individual pages. Almost entire WWW is dependent upon these links. To understand working of External Hyperlinks, consider the following diagram.
We simply use 'href' attribute with the <a> tag to create an external link. Consider the following diagram:
Syntax:
Example
Click Here
Output: [Click on the link to see how it works.]
These links are used to connect two sections of the same page. Internal hyperlinks are links to another section in the same webpage. Especially in tutorial kind of websites, headings of topics are usually developed as links to their explanations below on the same page. To understand working of Internal Hyperlinks, consider the following diagram.
As in this diagram, Links are created first and then Targets are created thereafter. Every link is connected to a particular target using a very special attribute id.
Links are created simply by using href attribute in the <a> tag. Similarly, targets are created using Headings or Paragraphs. The Heading is assigned a particular id which is given as value to the href attribute in the Link.
We use a pair of tags to create an internal link. At the place of the link, we use <a> tag with 'href' attribute and at the place of landing we use 'id' attribute with whatever tag. Consider the following diagram:
Syntax:
Example
Click Here for Topic 1
Click Here for Topic 2
This is explanation of topic 1
This is explanation of topic 2
Output: [Click on the link to see how it works.]