Link href attribute
Definition and usage
href
Set or return the URL of the linked document attribute.
See also:
HTML Reference Manual:HTML <link> href Attribute
HTML Reference Manual:HTML <link> Tag
Example
Example 1
Return the URL of the linked document:
var x = document.getElementById("myLink").href;
Example 2
Change stylesheet:
document.getElementById("myLink").href = "style2.css";
Syntax
Return href attribute:
linkObject.href
Set href attribute:
linkObject.href = URL
Attribute value
Value | Description |
---|---|
URL |
Specifies the URL of the linked resource/document. Possible values:
|
Technical Details
Return Value: | A string value representing the URL of the linked document. Returns the entire URL, including the protocol (such as http://). |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |