Anchor Tag in HTML – HTML Tutorial

This “Anchor Tag in HTML” post provides complete information about hyperlinks creation to other web pages, internal page links, links to emails, image links, links to files and much more using HTML anchor tag.


 

Anchor tag (<a>):

  • Hyperlinks we are using to open external web pages in the current window.
  • The HTML <a> element (or anchor element) creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL.
  • “href” stands for hyperlink reference and it is an attribute.
  • Here “Lear HTML online” is the identifier (hyperlink name displayed on the webpage).

 

Linking to External page: 

  • Following syntax is used to open external web pages either in the same window or in another window(using some attributes)

<a href=”https://www.java2python.com/”>
External Page Link
</a>

 

Linking to another section of the same page like bookmarks :

<a href=”#attr-href“>
Description of Same-Page Links
</a>

 

Creating a link to the image:

  • This example uses an image to link.
  • The page will open in a new browsing context that is a new page or a new tab.

<a href=”https://www.java2python.com” target=”_blank”>
<img src=”java2python.png” alt=”java2python page not availbale” />
</a>

 

Creating an email link :

  • It’s common to create links that open in the user’s email program to allow them to send a new message.
  • This is done with a mail to: link.
  • Here’s a simple example:
    <a href=”mailto:java2python.com@gmail.com”>Mail to www.java2python.com</a>

 

Code-1 :

<html>
<head> </head>
<body>
<a href=”https://www.java2python.com”>Lear HTML online</a>
</body>
</html>

 

By default, links will appear as follows in all browsers:
  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red

 

Code-2 :

<html>
<head> </head>
<body>
<a href=”http://www.google.com”>open google</a></br>
<a href=”abc.txt”>Open txt file</a></br>
<a href=”blog.png”>Open image</a></br>
<a href=”oceans.mp4″>Open video</a></br>
</body>
</html>


                 Sub Attributes in HTML – HTML Tutorial

Share this