Area coords Property
Example
Get the coordinates for a specific area in an image-map:
var x = document.getElementById("venus").coords;
The result of x will be:
124,58,8
Try it yourself »
Definition and Usage
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
The coords property is supported in all major browsers.
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