HTML Links

Used to create hyperlinks, allowing users to navigate between different web pages or resources on the internet.
Links are an essential part of web development and are created using the anchor tag <a> in HTML.


<a href="">This is a Link</a>

The href Attribute

Used to specify the URL of a hyperlink
The href attribute is used only in a (Anchor) tag.
The format of the href attribute is <a href="" >


<a href="">This is a Link</a>
<a href="/editor/web-compiler/">This is a Link</a>
<a href="web-compiler/">This is a Link</a>
Refer: Know more about how the file path work

The target Attribute

The target attribute is an optional attribute used within the anchor tag <a> in HTML.
It specifies where the linked content should be opened when the user clicks on the link.
The attribute can take various values to control how the link behaves.

Target Type



This link will open in the same tab or frame as the one the link was clicked in.


This link will open in a new browser tab.


This link will open in the parent frame (if used within frames). If the link is not within a frameset, it behaves the same as _self.


This link will open in the full window, breaking out of any frames (if used within frames).


This link will open in a specific named frame. Note that for this example, you need to have a frame with the name "myframe" defined in your HTML. If you don't have frames, this link will behave like _self.


<a href="" target="_self">_self - Open in same tab</a>
<a href="" target="_blank">_blank - Open in new tab</a>
<a href="" target="_parent">_parent - Open in parent frame</a>
<a href="" target="_top">_top - Open in full window</a>
<a href="" target="myframe">framename - Open in named frame</a>

Image Links

Keep the image link or path in the href attribute to open the image when clicked.


<a title="/BMR ONLINE TOOLS.ico">open the image</a>

Email Links

Email links are a type of hyperlink in HTML that allows users to initiate an email composition directly from a web page.
When a user clicks on an email link, their default email client (such as Outlook, Gmail, or Apple Mail) will open with the recipient's email address pre-filled in the "To" field.
There are placed in href attribute starting with maitto syntax. Syntax: <a href="mailto:[email protected]">Send email>


<a href="mailto:[email protected]">Send Email</a>
<a href="mailto:[email protected]?subject=Send your query.">Send Email</a>

Using Links for js

In JavaScript, you can use links in many ways. Lets see some of it
By handling the click event using the onclick attribute.
By manipulating the browser location directly using JavaScript functions.
by using js you dont need to use compulsorily href attribute or "a" tag.


<a href="#" id="myLink">Click Me</a>
    <button onclick="document.location=''">HTML Tutorial</button>

        document.getElementById('myLink').onclick = function() {
            window.location.href = '';

Quick Recap

Topics Covered

HTML Links
href attribute
Target attribute
Image Links and mail links
Using js for Links

Practice With Examples in Compilers

The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compile or Try on own Now

Example 1

Example 1 Example 2 Example 3 Example 4 Example 5