Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 710 Bytes

File metadata and controls

36 lines (24 loc) · 710 Bytes
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.

Value

A string.

Examples

// 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

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • The {{domxref("HTMLAnchorElement")}} interface it belongs to.