HTML Standard attribute: href
[this page | pdf | back links]
The HTML href attribute indicates the URL of the
page that link goes to (or for the <base> element
the URL that forms the base for relative URLS). It applies to <a>, <area>, <base> and <link> elements.
Valid attribute
values (when used with <a>,
<area>, <base>, <link> elements)
include:
Value
|
Description
|
URL
|
URL location of linked
document
|
If an element has an href attribute then the corresponding DOM
object usually supports the following additional properties which can be
thought of as variants of the href
attribute:
Value
|
Description
|
hash
|
Anchor part of href attribute
|
host
|
Hostname and port part
of href attribute
|
hostname
|
Hostname part of href attribute
|
origin
|
Returns protocol,
hostname and port part of href
attribute
|
password
|
Password part of href attribute
|
pathname
|
Pathname part of href attribute
|
port
|
Port part of href attribute
|
protocol
|
Protocol part of href attribute
|
search
|
Querystring part of href attribute
|
username
|
Username part of href attribute
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<a href="http://www.nematrian.com">link to www.nematrian.com</a>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("A");
x.href = "http://www.nematrian.com";
x.textContent = "link to www.nematrian.com";
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes