These take me back, but I'm trying to remember why I stopped using them. Did they go out of fashion? Or was it accessibility related?
These take me back, but I'm trying to remember why I stopped using them. Did they go out of fashion? Or was it accessibility related?
The era of imagemaps was one where they were raster images at a fixed size, and when CSS wasn’t particularly good for interesting positioning and layout. Once you acknowledge viewports are extremely variable in size, there’s very little place left for imagemaps, and so people stopped making the kinds of designs that could benefit from it; and once you had alpha channels and better CSS and cross-platform vector graphics, there was even less place for traditional client-side imagemaps.
(As for server-side imagemaps, ismap, no one ever really used them. A few years ago I deliberately used them in order to just barely support JavaScript-free operation on a toy just for the sake of it, but they’re very much a solution looking for a problem these days.)
I haven’t used an actual client-side imagemap for years; what I have done is used SVG as a form of better imagemap, not least because you can actually target the areas with styles. The imagemap in the article is approximately equal to this:
<svg viewBox="0 0 400 379" width="400" height="379" fill="none">
<image href="workplace.jpg" width="400" height="379"><desc>Workplace</desc></image>
<a href="computer.html">
<title>Computer</title>
<rect x="34" y="34" width="270" height="350"/>
</a>
<a href="phone.html">
<title>Phone</title>
<rect x="290" y="172" width="333" height="250"/>
</a>
<a href="coffee.html">
<title>Cup of coffee</title>
<circle cx="337" cy="300" r="44"/>
</a>
</svg>
But just think, now you can add rules like `a:hover { stroke: blue; stroke-width: 2px; } a:focus { fill: lime }` (maybe with some filter or mix-blend-mode).But their limitations were massive. Chiefly, in a period when dialup internet was becoming more common, an image map meant that before a user could interact with your website, they had to wait for a very slow download of a very large image that contained mostly text. You couldn't interact with them any more - no ability to select the text in them, or perhaps the reader had a different color/font preference? Tough luck.
When tables came out, they began to face competition, but they weren't defeated. Aside from table-first designs that mixed images and text, you could mostly do without imagemaps by cutting the image up, eliminating table borders/cellpadding/cellspacing and making careful use of colspan and rowspan, with a part of the image in each cell. This had most of the same user-side problems as imagemaps, but was easier for many people to maintain (I'm not sure quite why: I assume some people have trouble with thinking in terms of x/y coordinates and regions).
CSS thoroughly destroyed them. Everything an image map could do, tables+CSS and eventually CSS could do better. This was still ages before responsive became a concern, at a time when webpage maintainers would assume you used an 800x600 or 1024x768 screen with a maximized window and just ignore everyone who didn't match that.
Nowadays, any time an image map might look like the solution, the actual solution is SVG, which gives you everything an image map had but is moreover correct.
Back then we also had the lowsrc attribute for images, so that large image should have been preceded by a much smaller 1-bit version.