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=””>
External Page Link


Linking to another section of the same page like bookmarks :

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


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=”” target=”_blank”>
<img src=”java2python.png” alt=”java2python page not availbale” />


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=””>Mail to</a>


Code-1 :

<head> </head>
<a href=””>Lear HTML online</a>


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 :

<head> </head>
<a href=””>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>

                 Sub Attributes in HTML – HTML Tutorial

Share this