title | short-title | slug | page-type | browser-compat |
---|---|---|---|---|
HTMLAnchorElement: hostname property |
hostname |
Web/API/HTMLAnchorElement/hostname |
web-api-instance-property |
api.HTMLAnchorElement.hostname |
{{ApiRef("HTML DOM")}}
The HTMLAnchorElement.hostname
property is a
string containing the domain of the URL.
A string.
// An <a id="myAnchor" href="/en-US/docs/HTMLAnchorElement"> element is in the document
const anchor = document.getElementById("myAnchor");
anchor.hostname; // returns 'developer.mozilla.org'
{{Specifications}}
{{Compat}}
- The {{domxref("HTMLAnchorElement")}} interface it belongs to.