<area>
Definition
The HTML area
element is a part of an image map, and is used to define a clickable area on an image. It can be used to create hyperlinks within a single image that can be used to navigate to different pages or sections on a website.
Examples
<!DOCTYPE html>
<html>
<head>
<title>Example of the HTML area element</title>
</head>
<body>
<h1>Clickable Image Map</h1>
<p>Click on the different shapes in the image below to navigate to different pages:</p>
<img src="image.jpg" alt="Image map with clickable areas" usemap="##map">
<map name="map">
<area shape="rect" coords="0,0,150,150" href="page1.html" alt="Rectangle" title="Page 1">
<area shape="circle" coords="175,75,50" href="page2.html" alt="Circle" title="Page 2">
<area shape="poly" coords="275,0,325,50,375,0,400,100,375,150,325,100,275,150" href="page3.html" alt="Triangle" title="Page 3">
</map>
</body>
</html>
Attributes
The area
element has several attributes that can be used to define its properties, including alt
, coords
, href
, shape
, and title
.
Attribute | Description | Deprecated |
---|---|---|
alt | Specifies an alternative text for the area | No |
coords | Specifies the coordinates of the clickable area | No |
href | Specifies the destination URL for the area | No |
shape | Specifies the shape of the clickable area | No |
title | Specifies a title for the area | No |
Best Practices
Best practices for using the area
element include:
- Using the
alt
attribute to provide a text alternative for the area - Providing a meaningful
title
attribute for the area - Using a logical
shape
attribute to define the clickable area - Specifying the
coords
attribute to define the coordinates of the clickable area - Using a valid
href
attribute to provide the link for the area
Accessibility Considerations
When using the area
element, it is important to consider accessibility. This includes providing alternative text for the area using the alt
attribute, and ensuring that the shape
and coords
attributes are properly defined to create a logical and easily clickable area.
Browser Compatibility
Browser compatibility for the area
element varies, as not all browsers support the use of image maps. Some commonly used browsers that support the area
element include:
Chrome | Firefox | Microsoft Edge | Safari | Internet Explorer |
---|---|---|---|---|
Yes | Yes | Yes | Yes | No |