HTML Links – Hyperlinks

a hyperlink is use to jump on another page or related page linking. we can give hyperlink img, div, heading and Html Tag.

IMG Link

<a hrrf="http://www.simplycode.in/category/html/"><img src="http://www.simplycode.in/wp-content/uploads/2015/12/html5.png" /></a> 

DIV Link

<a hrrf="http://www.simplycode.in/category/html/"><div>Hyperlinks</div></a>

H1 To H6 Link

<h3><a hrrf="http://www.simplycode.in/category/html/">Hyperlinks</a></h3>

A local link (link to the same web site) is specified with a relative URL (without http://www….).

HTML Links – Colors

When you move the mouse over a link, two things will normally happen:

  • The mouse arrow will turn into a little hand
  • The color of the link element will change

By default, a link will appear like this (in all browsers):

  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red

You can change the default colors, by using styles:


<style>
a:link    {color:green; background-color:transparent;    text-decoration:none}
a:visited {color:pink; background-color:transparent; text-decoration:none}
a:hover     {color:red; background-color:transparent; text-decoration:underline}
a:active    {color:yellow; background-color:transparent; text-decoration:underline}
</style>  

HTML Links – The target Attribute

The target attribute specifies where to open the linked document.

<a href=”http://www.simplycode.com/” target=”_blank”>Visit Simplycode!</a>
Target ValueDescription
_blankOpens the linked document in a new window or tab
_selfOpens the linked document in the same frame as it was clicked (this is default)
_parentOpens the linked document in the parent frame
_topOpens the linked document in the full body of the window
framenameOpens the linked document in a named frame

Chapter Summary

 

  • Use the HTML <a> element to define a link
  • Use the HTML href attribute to define the link address
  • Use the HTML target attribute to define where to open the linked document
  • Use the HTML <img> element (inside <a>) to use an image as a link
  • Use the HTML id attribute (id=”value“) to define bookmarks in a page
  • Use the HTML href attribute (href=”#value“) to link to the bookmark