HTMLAreaElement: port property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The port property of the HTMLAreaElement interface is a string containing the port number of the <area> element's href. If the port is the default for the protocol (80 for ws: and http:, 443 for wss: and https:, and 21 for ftp:), this property contains an empty string, "".

This property can be set to change the port of the URL. If the URL has no host or its scheme is file:, then setting this property has no effect. It also silently ignores invalid port numbers.

See URL.port for more information.

Value

A string.

Examples

js
// An <area id="myArea" href="https://developer.mozilla.org:443/en-US/docs/HTMLAreaElement"> element is in the document
const area = document.getElementByID("myArea");
area.port; // Returns ''
js
// Another <area id="myArea" href="https://developer.mozilla.org:8888/en-US/docs/HTMLAreaElement"> element is in the document
const area = document.getElementByID("myArea");
area.port; // Returns:'8888'

Specifications

Specification
HTML
# dom-hyperlink-port-dev

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
port

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also