Image maps assign different clickable areas to different parts of one image. Each area needs a meaningful destination and alternative text. The important question is always where the link leads and whether the person reading the page can predict it.
What You Need to Know
They can be hard to maintain when pictures resize, since coordinate values refer to pixel positions. Ordinary clearly labeled links are usually simpler navigation.
The base element can also affect simple fragment links. Prefer normal paths unless you deliberately need a base URL.
Links are the pathways through a website. The words on a link should help someone choose where to go before clicking it.
Example: See It in Action
Here is a simple example to experiment with. Type it, save the file, and check what the browser displays.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<img src="images/campus-map.png" alt="Campus buildings" usemap="#locations">
<map name="locations">
<area shape="rect" coords="10,10,80,60" href="library.html" alt="Library">
</map>
Let’s Understand the Example
- Img displays an image. Src chooses the file and alt provides a useful text alternative.
- Map defines a set of clickable regions associated with an image.
- Area names one clickable region inside an image map.
- Src tells the browser where to find an image or other embedded resource.
- Alt supplies a text alternative for an image. Empty alt is appropriate for purely decorative images.
- Name is the key the browser normally sends when a form control is submitted.
An image appears only if its file path is correct. If it is informative, its alt text should share the same useful meaning; if it is decoration, empty alt text is often right.
What Should You See?
This example may change the document’s behavior or metadata rather than draw something obvious. Use your browser’s developer tools to inspect the actual elements and attributes.
Imagine this link is read out of context. Would its text still explain the destination? Rename unclear links before trying to make them look nicer with CSS.
Try It Yourself
- Replace the map's library area with an ordinary text link and compare ease of use.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Using a large image map without describing the areas to keyboard or screen-reader users.
- Avoid dead links, empty href values and clickable-looking text without a real destination.
Key Takeaways
- Image maps assign different clickable areas to different parts of one image.
- Img displays an image. Src chooses the file and alt provides a useful text alternative.
- The base element can also affect simple fragment links. Prefer normal paths unless you deliberately need a base URL.