anchor tag in html



1. The <a> tag defines an anchor. The HTML anchor element is used to create a link to a resource (another web page, a file, etc.) or to a specific place within a web page.An anchor can be used in two following ways:
  a: To create a link to another document, by using the href attribute.
  b: To create a bookmark inside a document, by using the name attribute.
2. The most important attribute of the a element is the href attribute, which indicates the link’s destination. By default, links will appear as follows in all browsers:
  a: An unvisited link is underlined and blue.
  b: A visited link is underlined and purple.
  c: An active link is underlined and red.
3. The <a> is supported in all major browsers.


Example 1 :



     <html>
     <head>
     <title>Anchor</title>
     </head>
     <body>
     <a href="http://20fingers2brains.blogspot.in">20 fingers 2 brains</a>
     </body>
     </html>
     

Demo :




In above example link is specified without target attribute, so the destined page will open in the same window.



Example 2 : Anchor with Target attribute


<html>
<head>
<title>Anchor</title>
</head>
<body>
<a href="http://20fingers2brains.blogspot.in" target="_blank">20 fingers 2 brains</a>
</body>
</html>


Demo :




Example 3 : Anchor with Destination



<html>
<head>
<title>Anchor</title>
</head>
<body>
<a href="http://20fingers2brains.blogspot.in#footer-wrapper" target="_blank">20 fingers 2 brains</a>
</body>
</html>


Demo :





Using "#" sign you can specify the destination you want to display in a particular page. In above example, after clicking on link http://20fingers2brains.blogspot.in home page will open showing fotter section.



0 comments:

Post a Comment