HTML Links

HTML Links

HTML Links are very necessary for all web pages.All web sites have links.HTML Links are hyperlinks.

Links help users jump from their current web pages location to another.

To make HTML Links we just need to use the <a> element with the href attribute that specifies a URL to a page.

HTML Link Structure


  • Start tag. <a>
  • href Attribute eg href="index.html"
  • Element Content. A text eg. Home Page. Its can also be an image and other HTML Elements.
  • End tag. </a>

Internal Linking Example:

Linking inside our directory.

<!doctype html>
<html>
<head>
    <title> Linking Page </title>
</head>
<body>
    <a href="hello_world.html"> Click here </a>
</body>
</html>

Output:


After clicking Click here



⚠️Note❗ The Linked file hello_world.html  saved in the same path on link.html file in local storage.

External Linking Example:

<!doctype html>
<html>
<head>
    <title> Linking External Page </title>
</head>
<body>
    <a href="https://www.wikipedia.org"> Wikipedia </a>
    </body>
</html>

Output:


After Clicking Wikipedia

Opening Link in New Tab Example:

We can easily open a link in a new tab.
To do it we need to use the target attribute with the value _blank.
This would be helpful if you do not want your visitors to leave your website.

<!doctype html>
<html>
<head>
    <title> Linking External Page </title>
</head>
<body>
    <a href="https://www.wikipedia.org" target="_blank"> Wikipedia </a>
    </body>
</html>


    
                                                                                

Post a Comment

Post a Comment (0)