This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Image map" – news ·newspapers ·books ·scholar ·JSTOR(September 2023) (Learn how and when to remove this message) |
InHTML andXHTML, animage map is a list of coordinates relating to a specificimage, created in order tohyperlink areas of animage to different destinations (as opposed to a normal image link, in which the entire area of the image links to a single destination). For example, a map of the world may have each country hyperlinked to further information about that country. The intention of an image map is to provide an easy way of linking various parts of an image without dividing the image into separate image files.
Server-side image maps were first supported inMosaic (web browser) version 1.1.[1] Server-side image maps enable theweb browser to send positional information to the server about where the user clicks within an image. This allows the server to make pixel-by-pixel decisions about what content to return in response (possible methods are to use image mask layers, database queries, or configuration files on the server).
TheHTML code for this type of server-side image map requires the<img> tag to be inside an anchor tag<a>...</a> and the<img> must include theismap attribute.
<ahref="/imagemapper"><imgsrc="image.png"ismap/></a>
When the user clicks inside the image the browser will append the X and Y coordinates (relative to the upper-left corner of the image) to the anchorURL as aquery string and will access the resultingURL[2] (for example,/imagemapper?3,9).
If the browser does not supportismap then thequery string must not be added to the anchorURL and the server should respond appropriately (for example, by returning a text-only navigation page).
Client-side image mapswere introduced inHTML 3.2, and do not require any special logic to be executed on the server (they are fully client-side). They also do not require anyJavaScript.
A client-side imagemap in HTML consists of two parts:
<img> tag. The image tag must have an attributeusemap, which names the imagemap to use for this image (multiple imagemaps may exist on a single page).<map> element, and inside that,<area> elements, each of which defines a single clickable area within the imagemap. These are similar to the<a> tag defining whichURL should be opened for an ordinary web link. Atitle attribute may be provided, which may be rendered as atooltip if a desktop user hovers their mouse pointer over the area. Forweb accessibility reasons, it is often important – and in some cases it may even be a legal or contractual requirement – to provide analt attribute describing the link thatscreen reader software can read to, for example,blind users.[3]The<area> elements can be rectangles (shape="rect"), polygons (shape="poly") or circles (shape="circle").Shape-Values are coordinate-pairs. Every pair has an X and a Y value (from left/top of an image) and is separated with a comma.
The following example defines a rectangular area ("9,372,66,397"). When a user clicks anywhere inside this area, they are taken to theEnglish Wikipedia's home page.
<imgsrc="image.png"alt="Website map"usemap="#mapname"/><mapname="mapname"><areashape="rect"coords="9,372,66,397"href="https://en.wikipedia.org/"alt="Wikipedia"title="Wikipedia"/></map>
A more recent approach is to overlay links on an image usingCSS absolute positioning; however, this only supports rectangular clickable areas. This CSS technique may be suitable for making an image map work properly oniPhones, which can fail to rescale pure HTML image maps correctly.

It is possible to create client-side image maps by hand using a text editor, but doing so requires web designers to know how to code HTML as well as how to enumerate the coordinates of the areas they wish to place over the image. As a result, most image maps coded by hand are simple polygons.
Because creating image maps in a text editor requires much time and effort, many applications have been designed to allow web designers to create image maps quickly and easily, much as they would create shapes in avector graphics editor.
Image maps which do not make their clickable areas obvious risk subjecting the user tomystery meat navigation. Even when they do, where they lead may not be obvious. This can be partially remedied with rollover effects.[4]
Because theScalable Vector Graphics (SVG) image format provides its own mechanisms for adding hyperlinks[5] and other, more sophisticated forms of interactivity[6] to images, traditional image map techniques are generally not necessary when working with vector images in the SVG format.