Creating Image Map
Creating Image Map
Chapter 2 1
Cont’d
Image map is defined by the <map> element with <area> elements
The idea is to be able to perform different actions depending on where in the
image you click.
It is an inline element and belongs to the phrasing content ----> Flow content
model.
The <map> tag has one required attribute called name that gives the map a
name so that it can be referenced.
The name attribute must:
Has a non-empty value with no space characters
Has a unique value – two map element in the same document not allowed to
have the same name.
2
Cont’d
How Does it image map Works?
The image is inserted using the <img> tag.
Here the <img> element is different from other images because it require a
usemap attribute
Usemap attribute
Its value starts with a # followed by the name of the image map.
Used to create a relationship between the image and the image map.
Then, the <map> element is used to create an image map, and is linked to the
image by using the required name attribute.
Then, the clickable areas are defined and added using an <area> element.
3
Cont’d
Example 1:
4
Cont’d
The <area> element
It defines an area inside an image map that has predefined clickable areas.
Allows geometric areas on an image to be associated with hypertext link.
Used only within a <map> element.
It is defined with (required) attributes shape and coords.
Shape attribute - specifies the shape of the clickable area such as rectangle,
circle, square, and polygon.
Coords attribute - defines the coordinates of areas inside the image.
5
Cont’d
7
Cont’d
Example 2: