W3Schools.com

Area coords Property

Area Object Reference Area Object

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.

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

Syntax

areaObject.coords=value

The coords property can have one of the following 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


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The coords property is supported in all major browsers.


Example

Example

Return the coordinates for the "Venus" area in the image-map:

<html>
<body>

<img src="planets.gif"
width="145" height="126"
usemap="#planetmap" />

<map name="planetmap">
<area id="venus" shape="circle"
coords="124,58,8"
alt="Venus"
href="venus.htm" />
</map>

<p>Coordinates for Venus are:
<script type="text/javascript">
document.write(document.getElementById("venus").coords);
</script>
</p>

</body>
</html>

The output of the code above will be:

Coordinates for Venus are: 124,58,8

Try it yourself »


Area Object Reference Area Object
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE