- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- 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 - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- 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 Code Builder
- HTML References
- 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 - <map> Tag
HTML offers excellent assistance for enhancing the interactivity of websites. HTML offers the image mapping feature when we want to make the graphics more interactive. Using image mapping, we can navigate between images within the same frame and interact with the image. When we wish to accomplish a feature like zooming in on the website's image, this feature is helpful. There will be a clickable area on each image, and we can set the URLs or other images to redirect when the user clicks on that area.
An image map is defined by the combination of the HTML <area> and <map> tags. An image map consists of an image with clickable portions; by clicking the image, a new window or the specified location will open. The <area> element, which specifies the location and type of the area, may contain more than one instance. Without separating the image, you may quickly link any portion of image to other documents using the <map> element.
Syntax
Following is the syntax for HTML <map> tag −
<map name="">...</map>
Specific Attributes
The HTML <map> tag also supports the following additional attributes −
Supported attribute for the <html> tag −
S.No. | Attribute & Description |
---|---|
1 | name Defines a unique name for the map tag. |
Example
Let’s look at the following example, where we are going to use the <map> tag and navigate to another page by specifying the link.
<!DOCTYPE html> <html> <body style="background-color:#EAFAF1"> <img src="https://www.tutorialspoint.com/cg/images/logo.png" alt="Workplace" usemap="#workmap" width="200" height="100"> <map name="workmap"> <area shape="rectangle" coords="33,45,271,300" alt="tutorial" href="https://www.tutorialspoint.com/index.htm"> </map> </body> </html>
When we execute the above code, it will generate an output consisting of an image along with CSS applied to the webpage. When the user clicks the image, it will navigate to the link we have mentioned in the code.
Example
Consider another scenario where we are going to use the <map> tag to navigate to another image within the same frame.
<!DOCTYPE html> <html> <body> <center> <p>Click on Images where the cursor clickable. </p> <img src="https://www.tutorialspoint.com/cg/images/logo.png" alt="logo" usemap="#tutorial"> <map name="tutorial"> <area shape="rect" coords="0, 0, 52, 52" alt="tutorial" href="https://www.tutorialspoint.com/html/images/html.jpg"> </map> </center> </body> </html>
On running the above code, the output window will pop up, displaying the image uploaded to the webpage. When the user clicks on the image, it navigates within the same frame and displays another image.