HTML Image Maps
Subject: html
HTML Image Maps
Image Maps allow users to click on different parts of a single image and navigate to different destinations. This is achieved using the <map> and <area> tags in conjunction with the <img> tag.
π Basic Concept
You define an image with the usemap attribute and create clickable regions using the <area> tag inside a <map>.
Syntax:
π§ Shape Attribute Values
rect: Rectangle (coords= x1, y1, x2, y2)circle: Circle (coords= centerX, centerY, radius)poly: Polygon (list of x,y pairs)default: Covers entire image
β Example
π¨ Styling Image Maps
Image maps themselves cannot be styled directly with CSS. However:
- You can style the 
<img>element (borders, responsiveness, etc.) - You can enhance 
<area>elements using JavaScript (e.g., highlight effects on hover) 
π‘ Use Cases for Image Maps
- Interactive geographic maps (clickable countries or states)
 - Product feature diagrams (clickable parts of a product)
 - Real estate floor plans (click on rooms)
 - Infographics with multiple links
 
π Key Takeaways
- Use 
<img usemap="#mapname">to associate an image with a map - Define clickable zones using 
<area>inside<map name="mapname"> - Use 
shapeandcoordsto define the type and position of clickable regions - Add 
alttext for accessibility - You canβt style 
<area>tags with CSS, but interactivity can be added via JavaScript 
π·οΈ Tags Reference
<img>: The image being mappedusemap: Links the image to a named<map><map>: Container for<area>tags<area>: Defines a clickable area (shape, coords, link, alt)
Advertisement Slot 1
Advertisement Slot 2