HTML Image Maps
Image maps are images with clickable areas (sometimes referred to as "hotspots") that usually link to another page. If used tastefully, image maps can be really effective. If not, they can potentially confuse users.
To create an image map:
- First, you need an image. Create an image using the usual method (i.e. via an image editor, then save as a gif or jpeg into your website's image folder).
- Use the HTML
<map>tag to create a map with a name. Inside this tag, you will specify where the clickable areas are with the HTML
- Use the HTML
<img>tag to link to this image. In the img tag, use with the
usemapattribute to define which image map to use (the one we just specified).
Image Map Example
OK, compared to our previous lessons, this code is looking quite complex. However, once you really study it, it is not that complex. All we are doing, is specifying an image, then we are creating a map with coordinates. The hardest part is getting all the coordinates right.
In our example, we use the
<area> tag in conjunction with the
coord attributes. These accept the following attributes:
|shape||Defines a shape for the clickable area. Possible values:
|coords||Specifies the coordinates of the clickable area. Coordinates are specified as follows:
You can use the above attributes to configure your own image map with as many shapes and clickable regions as you like.
Enjoy this page?
- Link to this page (copy/paste into your own website or blog):
- Link to Quackit using one of these banner ads.
Thanks for supporting Quackit!