What is the HTML <area> Tag?

The HTML <area> tag is an essential element used to define specific clickable areas within an image map. An image map is a graphical image where different parts of the image can be linked to different destinations.

This tag allows developers to create interactive regions within an image that users can click on to navigate to various URLs or trigger certain actions.

The <area> tag is always nested within a <map> tag, which groups multiple <area> tags together and links them to a specific image.

Why Use the <area> Tag?

The primary purpose of the <area> tag is to make images more interactive by defining multiple hotspots, each associated with a different link.

This can be particularly useful in situations where a single image represents multiple categories, locations, or sections that users might want to explore.

For example, in a world map image, you can define separate <area> elements for each country, allowing users to click on any country to learn more about it.

Using image maps with <area> tags can enhance user experience by making navigation more intuitive and visually appealing.

It also helps in reducing the need for multiple images or separate buttons, thereby simplifying the design while keeping the interface clean.

How to Use the <area> Tag?

How to Use the area Tag
How to Use the area Tag

To use the <area> tag, you first need to define an image map using the <map> tag, assign it an ID, and then link it to an image using the usemap attribute of the <img> tag. Within the <map> tag, you can define various <area> elements, each specifying a different region of the image and linking it to a unique URL or action.

Here’s a basic example of how to use the <area> tag:

In this example, the usemap attribute of the <img> tag links the image to the map defined by the <map> tag with the ID #worldmap.

The <area> tags within the <map> element define clickable regions of the image with specific shapes and coordinates.

Attributes of the <area> Tag

The <area> tag has several attributes that help define its functionality:

1. shape: Specifies the shape of the clickable area. Possible values are:

  • rect: Defines a rectangular area. Requires four coordinates (x1, y1, x2, y2) for the top-left and bottom-right corners.
  • circle: Defines a circular area. Requires three coordinates (center x, center y, radius).
  • poly: Defines a polygonal area. Requires a series of coordinates for each vertex of the polygon.
  • default: Defines the entire area of the image as clickable, which overrides any other shapes.

Example:

2. coords: Specifies the coordinates for the shape. The format of the coordinates depends on the shape. For rect, it is x1, y1, x2, y2. For circle, it is x, y, radius. For poly, it is a series of x, y pairs.

Example:

3. href: Defines the URL to which the user will be redirected when they click on the area.

Example:

4. alt: Provides alternative text for the area, similar to the alt attribute for images. This is useful for accessibility and SEO purposes.

Example:

5. target: Specifies where to open the linked document. It can take values like _self, _blank, _parent, _top, etc.

Example:

6. rel: Defines the relationship between the current document and the linked document. Common values include nofollow, noopener, noreferrer.

Example:

Conclusion

The HTML <area> tag is a powerful tool for creating interactive image maps that improve navigation and user experience.

By defining specific clickable areas within an image, you can guide users through a visual interface in a more engaging way.

Understanding and properly utilizing the attributes of the <area> tag allows for a wide range of possibilities in web design, making it a valuable element for any developer’s toolkit.

Browser Support

For questions and feedback related to the content, you can visit our contact page and reach out to us through our social media accounts.

YouTube | Twitter (X) | Instagram | Contact Me Page