HTML href Attribute

❮ HTML Attributes


<a href="">Visit Google</a>


The Hyperlink of the page used to navigate.

Standard Syntax

<element href="URL">

Browser Support


Applies to:

The href attribute can be used on the following element:

Element Attribute
<a> href
<area> href
<base> href
<link> href

Attribute Values

Value Description

Value can be

  • An absolute URL - navigate to within or another web site ( href="")
  • A relative URL - navigate to within a web site ( href="index.html")
  • Link to an element with a specified id within the page ( href="#section")
  • Protocols ( https://, ftp://, mailto:, file:, etc..)
  • A JavaScripts ( href="javascript:alert('Hello');")

<area> Example

The Hyperlink of the page used to navigate.

Note: If the href attribute is not exist and the <area> tag will not be a hyperlink.

<img src="img/desk.jpg" usemap="#image-map">

<map name="image-map">
    <area target="_blank" alt="Computer" title="Computer" href="img/computer.png" coords="365,99,905,783" shape="rect">
    <area target="_blank" alt="Cup" title="Cup" href="img/cup.png" coords="1047,672,97" shape="circle">
    <area target="_blank" alt="Mobile" title="Mobile" href="img/mobile.png" coords="960,385,1040,541" shape="rect">
    <area target="_blank" alt="Book" title="Book" href="img/book.png" coords="175,426,96,527,20,664,232,755,298,628,364,505" shape="poly">

<base> Example

The Hyperlink of the page used to all relative URLs in the page.

	<base href="img/" target="_blank">
	<img src="image.jpeg" width="50" height="50" alt="demo">

<link> Example

The href attribute specifies the URL of the linked resource. A URL might be absolute or relative.

	<link rel="stylesheet" href="demo/demo.css">
❮ HTML Attributes