Your input fuels progress! Share your tips or experiences on prioritizing mental wellness at work. Let's inspire change together!

Join the discussion and share your insights now!

Comments 0


Creating Hyperlinks and Anchors in HTML

hyperlinks in html


A Website is a collection of Web pages that facilitate information sharing on the Internet. There should be some mechanism to allow the user to navigate through the Web pages of a Website. It should also enable the user to view the Web pages of other Websites if required. These tasks can be achieved by creating hyperlinks in HTML.


A hyperlink is referred to as a link. It refers to linking to another Web page or a section of the same Web page.

The A (anchor) element is used to create a hyperlink. You can specify text or an image as a hyperlink. When you move the mouse over such content, the cursor changes into a hand with its index finger pointing towards the content. This means that clicking them will take you to the respective link. To specify the linked page section or linked Web page, you must use the attributes of the A element.

  • href: Specifies the URL of the Web page to be linked or the value of the name attribute.
  • hreflang: Indicates the language of the destination URL.
  • name: Specifies the section of the Web page, which is to be linked.

The basic syntax to provide a hyperlink is always the same. The <a> tag is used to provide a hyperlink. This contains the href= attribute that would contain the link to a URL or the path of a Web page. An example of a href attribute code is as follows:

<a href="">

The description and reference text that will serve as a hyperlink must be provided before closing the <a> tag by using </a>.

        <a href="">Click to view TEXVN Website</a>

Target Attributes

The target attribute of the A element specifies the location where the linked Web page will open when a link is clicked.

You can assign values to the target attribute.

  • _blank: Loads the target URL in a new blank window.
  • _self: Loads the target URL in the same window as that of the current Web page.
  • _top: Loads the target URL in the complete area of the window.

Hyperlink to an E-mail Address

Hyperlinks can even be applied to e-mail addresses in the same way as they can be given to Web pages. Various tasks can be performed when a hyperlink is given to an e-mail. Some of these tasks include starting the default e-mail client, creating a new message, inserting the recipient's address, adding the subject line, and so on.

To add an e-mail to a hyperlink, the href= attribute must be used and followed by the mailto: email address. 

<a href="mailto:">TEXVN E-mail</a>

To automatically add a subject line to the new e-mail message, the ?subject= attribute must be inserted after the e-mail address.

<a href="mailto: to TEXVN">TEXVN E-mail</a>

Hyperlinks to Other Types of Content

Hyperlinks can be used to not only refer to another Web page or e-mail address but also can be used to link to other files and documents. Some of the files that are commonly linked on Web pages using hyperlinks are zip files (.zip), executable files (.exe), documents (.doc), PDF reader files (.pdf), and so on. Hyperlinks can also be used to link to graphical jpg and .gif files. To specify a file instead of the Web page, the name of the file must be provided in the <a> tag.

<a href="">Click to download the compressed zip file</a>

HTML creating hyperlinks and anchors in HTML hyperlinks in HTML anchors in HTML Target Attributes in HTML Hyperlink to an email address hyperlinks to other types of content types of links in HTML