Hyperlinks and Anchors in HTML

In this HTML article we are going to Hyperlinks and Anchors in HTML, Hyperlinks and anchors are integral components of HTML (Hypertext Markup Language), the language used to create web pages. they are the key elements that allow users to navigate through different web pages, explore the Internet, and access information with easy.

 

 

Hyperlinks and Anchors in HTML

In HTML hyperlinks are created by using anchor tag <a>. these tags are used to specify the target location, also known as destination of the hyperlink. destination can be another web page, specific section of web page, or even downloadable file such as PDF or an image.

 

 

This is the syntax for HTML anchor tag

In this code href stands for hypertext reference, which is the attribute that specifies destination of the hyperlink. destination can be URL, file name or an anchor on the same page. Link Text is the visible text that the user clicks on to activate the hyperlink.

 

 

For example this code creates hyperlink to GeeksCoders homepage:

When user clicks on the Go to GeeksCoders link, the browser will open new tab or window and display GeeksCoders homepage.

 

 

Anchors on the other hand are used to create internal links within web page. An anchor is created by using anchor tag with unique identifier specified in name attribute. Anchors are usually placed at the beginning of the section to which the link will point.

 

This is the syntax

In this code name is the attribute of specifies unique identifier for the anchor. anchorName is the identifier name for the anchor which can be any text string without spaces. Section Title is the visible text that represents the section.

 

 

For example the following code creates an anchor with identifier section1:

 

To create hyperlink to this anchor we have used the anchor tag with href attribute set to #anchorName where anchorName is the identifier name of the anchor:

when the user clicks on Go to Section 1 link the browser will scroll down to the anchor with the identifier section1 and display the section.

 

 

Learn More on Python

Leave a Comment