Area coords Property

❮ Area Object

Example

Get the coordinates for a specific area in an image-map:

var x = document.getElementById("venus").coords;
Try it Yourself »

Description

The coords property sets or returns the value of the coords attribute of an area.

The coords attribute specifies the x and y coordinates of an area.

The coords attribute is used together with the shape attribute to specify the size, shape, and placement of an area.

Tip: The coordinates of the top-left corner of an area are 0,0.

Tip: Use the shape property to set or return the value of the shape attribute of an area.


Browser Support

Property
coords Yes Yes Yes Yes Yes


Syntax

Return the coords property:

areaObject.coords

Set the coords property:

areaObject.coords = value

Property Values

Value Description
x1, y1, x2, y2 If the shape attribute is set to "rect", it specifies the coordinates of the top-left corner and the bottom-right corner of the rectangle
x, y, radius If the shape attribute is set to "circle", it specifies the coordinates of the circle center and the radius
x1, y1, x2, y2, .., xn, yn If the shape attribute is set to "poly", it specifies the coordinates of the edges of the polygon. If the first and last coordinate pairs are not the same, the browser must add the last coordinate pair to close the polygon

Technical Details

Return Value: A String, representing a comma-separated list of coordinates

More Examples

Example

Change the coordinates for a specific area in an image-map:

document.getElementById("venus").coords = "90, 58, 3";
Try it Yourself »

Related Pages

HTML reference: HTML <area> coords attribute


❮ Area Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.