Easy Tutorial
❮ Event Img Onabort Prop Search Autofocus ❯

Anchor href Attribute


Definition and Usage

The href attribute sets or returns the value of the href attribute in a link.

The href attribute specifies the URL of the linked resource.

Syntax

Set href attribute:

Return href attribute:

Value Description
URL The URL of the linked resource

Browser Support

All major browsers support the href attribute.


Example

Return the value of the href attribute in a link:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>tutorialpro.org(tutorialpro.org)</title> 
</head>
<body>

<p><a id="tutorialpro" href="//www.tutorialpro.org/">tutorialpro.org</a></p>
<script>
document.write("Return href link: ");
document.write(document.getElementById('tutorialpro').href);
</script>

</body>
</html>

❮ Event Img Onabort Prop Search Autofocus ❯