Area coords attribute

Definition and Usage

coords Attribute sets or returns the area's coords attribute Value.

coords Attribute specifies the x and y coordinates of the area.

coords Attributes, together with the shape attribute, are used to specify the size, shape, and position of the area.

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

Hint:Use Shape Attribute Set or return the area's Shape Attribute Value.

Instance

Example 1

Get the coordinates of a specific area in the image map:

var x = document.getElementById("venus").coords;

Try It Yourself

Example 2

Change the coordinates of a specific area in the image map:

document.getElementById("venus").coords = "129,161,10";

Try It Yourself

Syntax

Return coords attribute:

areaObject.coords

Set coords attribute:

areaObject.coords = value

Attribute Value

Value Description
x1, y1, x2, y2 If the shape attribute is set to "rect", it specifies the coordinates of the top-left and bottom-right corners 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 polygon edges.

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 value representing a list of coordinates separated by commas.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Related Pages

HTML Reference Manual:The coords attribute of the HTML <area> tag