area
elementmap
element ancestor.alt
coords
shape
href
target
rel
media
hreflang
type
interface HTMLAreaElement : HTMLElement { attribute DOMString alt; attribute DOMString coords; attribute DOMString shape; stringifier attribute DOMString href; attribute DOMString target; attribute DOMString rel; readonly attribute DOMTokenList relList; attribute DOMString media; attribute DOMString hreflang; attribute DOMString type; // URL decomposition IDL attributes attribute DOMString protocol; attribute DOMString host; attribute DOMString hostname; attribute DOMString port; attribute DOMString pathname; attribute DOMString search; attribute DOMString hash; };
The area
element represents
either a hyperlink with some text and a corresponding area on an
image map, or a dead area on an image map.
If the area
element has an href
attribute, then the area
element represents a hyperlink. In this case, the alt
attribute must be present. It specifies the text of the hyperlink.
Its value must be text that, when presented with the texts
specified for the other hyperlinks of the image map, and with the alternative text of the
image, but without the image itself, provides the user with the
same kind of choice as the hyperlink would when used without its
text but with its shape applied to the image. The alt
attribute may be left blank if there is
another area
element in the same image map that points to the same resource and
has a non-blank alt
attribute.
If the area
element has no href
attribute, then the area represented
by the element cannot be selected, and the alt
attribute must be omitted.
In both cases, the shape
and coords
attributes specify the area.
The shape
attribute is an enumerated attribute. The following
table lists the keywords defined for this attribute. The states
given in the first cell of the rows with keywords give the states
to which those keywords map.
State | Keywords |
---|---|
Circle state | circle |
Default state | default |
Polygon state | poly |
Rectangle state | rect |
The attribute may be omitted. The missing value default is the rectangle state.
The coords
attribute must, if
specified, contain a valid list of integers. This
attribute gives the coordinates for the shape described by the
shape
attribute.
In the circle state, area
elements must have a coords
attribute present, with three
integers, the last of which must be non-negative. The first integer
must be the distance in CSS pixels from the left edge of the image
to the center of the circle, the second integer must be the
distance in CSS pixels from the top edge of the image to the center
of the circle, and the third integer must be the radius of the
circle, again in CSS pixels.
In the default state state, area
elements must not have a coords
attribute. (The area is the whole
image.)
In the polygon state, area
elements must have a coords
attribute with at least six
integers, and the number of integers must be even. Each pair of
integers must represent a coordinate given as the distances from
the left and the top of the image in CSS pixels respectively, and
all the coordinates together must represent the points of the
polygon, in order.
In the rectangle state, area
elements must have a coords
attribute with exactly four
integers, the first of which must be less than the third, and the
second of which must be less than the fourth. The four points must
represent, respectively, the distance from the left edge of the
image to the left side of the rectangle, the distance from the top
edge to the top side, the distance from the left edge to the right
side, and the distance from the top edge to the bottom side, all in
CSS pixels.
The target
,
rel
, media
, hreflang
, and type
attributes must be omitted if the
href
attribute is not present.