HTML Link are two types one is link that is used in head section and the other one is anchor link. Link tag is used to link external style sheets or css files. And anchor link is to add links to pages within websites or to external websites. The <a> is an anchor tag and it defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link’s destination.


HTML Link Tag

The rel attribute in <link> tag defines the relationship between a document and an external resource. This <link> tag is most used to link to style sheets.

Syntax of an HTML Link tag

[html] <head>
<link rel="stylesheet" type="text/css" href="style.css">

HTML Link Tag – Anchor <a> tag

Syntax of an anchor <a> tag
Hyperlink text will be added in between opening and closing anchor tag. And destination url will be added to anchor link using href attribute.
[html] <a href="">Link text here</a>

1) HTML Link: New Window

If you want to open this link in new window, then add target attribute and the value is _blank
[html] <a href="" target="_blank">Link text here</a>

2) HTML Link: Email Link

If you want to add an email link, then use mailto: in href attribute.
[html] <a href="mailto:contact@example[dot]com">Contact Us</a>

3) HTML Link: Named Anchors

Named anchor links are used to move through different sections of long single html document. Here is the sample code for named anchors

[html] <p>Link Targets<a name="named_anchor_link"></p>

For calling this named anchor in <a> tag, add html page link then hash symbol then named anchor.
[html] <a href="your-page.html#named_anchor_link" target="_blank">Link here</a>

Vivek Vengala

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: