- 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 - Image Map
An image map in HTML enables specific areas of an image to be clickable, acting as links to different destinations. This technique is useful for creating complex navigation systems or interactive graphics on a webpage.
By defining various shapes (rectangles, circles, polygons) within an image, each with its own associated link, developers can create dynamic and interactive visual content that enhances user engagement and navigation.
Why to use Image Map?
Image maps in HTML efficiently create interactive graphics by defining clickable regions within an image. This allows users to interact with different image parts, triggering specific actions or links.
Image maps are useful for creating complex navigation, interactive diagrams, or engaging visual experiences, enhancing user engagement and interactivity on web pages.
HTML <map> Tag
In HTML, the <map> tag is used to create a client-side image map, turning specific regions of an image into interactive elements. This allows users to click on different areas of the image, triggering various actions. The <map> element serves as a container for <area> elements, each defining a clickable region with specific attributes.
<map name="world map"> <!-- Define your clickable areas here --> </map>
When used in conjunction with the <img> tag, the <map> tag establishes a connection between the image and its associated map. This enables web developers to create dynamic and interactive content by defining distinct clickable zones within an image.
HTML <area> Tag
The <area> tag in HTML is used within the <map> element to define clickable regions on an image. It specifies the shape, coordinates, and associated actions for each clickable area.
Syntax
<area shape="shape_values" coords="coordinates" href="url" alt="Description">
Rectangular Area
We have to pass "rect" as value if need the area in rectangular shape. Rectangles require coordinates for the top-left and bottom-right corners.
<area shape="rect" coords="x1,y1,x2,y2" href="url" alt="Description">
x1, y1: Coordinates of the top-left corner.
x2, y2: Coordinates of the bottom-right corner.
Circular Area
We have to pass "circle" as value if need the area in circular shape. Circles need the center coordinates and radius.
<area shape="circle" coords="x,y,r" href="url" alt="Description">
- x, y: Coordinates of the circle's center.
- r: Radius of the circle.
Polygon Area
We have to pass "poly" as value if need the area in the shape of any polygon. Polygons require a series of coordinates to form the shape. This can be used to create any shape whether it be a mango or apple.
<area shape="poly" coords="x1,y1,x2,y2,..,xn,yn" href="url" alt="Description">
Where, x1, y1, ..., xn, yn: Coordinates forming the polygon.
These shapes enable the creation of interactive image maps, enhancing user engagement by associating distinct actions with specific areas within an image.
HTML Image Map
To create an image map in HTML, follow these steps with a code example.
- Step 1 - Prepare your image: Begin with an image you want to turn into an image map. For this example, let's use an image named ".jpg."
- Step 2 - Define the image map: Use the <map> tag to define the image map, and give it a unique name using the name attribute.
- Step 3 - Define clickable areas: Within the <map> element, you can define clickable areas using <area> tags. Specify the shape (rect, circle, or poly), the coordinates, and the URL to link to. Here's an example with a clickable rectangle.
Repeat Step 3 for each clickable area you want to create within the image. Close the HTML file and save it with .html extension.
Example
<!DOCTYPE html> <html> <head> <title>Image Map Example</title> </head> <body> <img src= "https://www.tutorialspoint.com/images/logo.png" usemap="#image_map"> <map name="image_map"> <!-- Define your clickable areas here --> <area shape="circle" coords="45,32,49" href="index.htm" alt="tutorialspoint"> <area shape="rect" coords="245,50,85,9" href="tutorialslibrary.htm" alt="tutorials_library"> </map> </body> </html>
On executing the above example, a page with Tutorialspoint logo will be displayed. If you click on the circle in the logo, the page will be redirected to the homepage of tutorialspoint and, if you click on “tutorials” (rectangular area map) you will be redirected to our tutorials library.
You can add more ‘<area>’ elements to create different clickable regions on the image, connecting them to different URLs or actions per your requirements. This provides an interactive experience for your website visitors.