- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - coords Attribute
HTML coords attribute is used to set the coordinates of an area in an image map.
It is used together with the shape attribute to specify the size, shape, and placement of an area. The coordinates of the top-left corner of an area are (0,0). The coords attribute is not used within the <area> element if the shape is set to default.
Syntax
<area coords = "coordinates_values">
Following are the values and descriptions of the coords attribute
coords value | Descriptions |
---|---|
x1, y1, x2, y2 |
Specifies the coordinates of the top-left and bottom-right corners of the rectangle (shape = "rect"). |
x, y, radius |
Specifies the coordinates of the circle and the radius (shape = "circle"). |
Applies On
Below listed elements allow using of the HTML coords attribute
Element | Description |
---|---|
<area> | HTML <area> tag specifies the areas of the image, mapping that can be clicked on or are active areas that are linked to by hyperlinks. |
Examples of HTML coords attribute
Bellow examples will illustrate the HTML coords attribute, where and how we should use this attribute!
Define clickable area in an image
In the following example, we are using the HTML ‘coords’ attribute within the image <area> element to set coordinates of an area in an image. In the output screen when you click yellow area you will redirect to HTML page.
<!DOCTYPE html> <html> <head> <title>HTML coords attribute</title> </head> <body> <img src="html/images/rect.jpg" alt="Rectangle" border="0" usemap="#tutorials" /> <map name="tutorials"> <area shape="rect" coords="31,101,164,157" alt="HTML Tutorial" href="/html/index.htm" target="_blank"> </map> </body> </html>
Define multiple clickable area in single image
Here we define three different area in single image when clicked will be redirected accordingly
<!DOCTYPE html> <html> <head> <title>HTML area Tag</title> </head> <body> <img src="/images/usemap.gif" alt="usemap" border="0" usemap="#tutorials" /> <map name="tutorials"> <area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27" href = "/perl/index.htm" alt = "Perl Tutorial" target = "_blank"> <area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial" href = "/html/index.htm" target = "_blank"> <area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial" href = "/php/index.htm" target = "_blank"> </map> </body> </html>
How to get coordinates of an image
Following are steps to get coordinates of an image
- Open any image on the Paint app.
- Click on resize and change resize unit from percentage to pixel.
- Give the same pixel width and height to your image in HTML.
- Highlight the top-left corner of that part of the image, and you will see the coordinates in your paint application's bottom left corner in px(x1, y1).
- Highlight the bottom-right corner of that part of the image, and you will see the coordinates in your paint application's bottom left corner in px(x2, y2).
Supported Browsers
Attribute | |||||
---|---|---|---|---|---|
coords | Yes | Yes | Yes | Yes | Yes |
To Continue Learning Please Login
Login with Google