HTML area tag

The <area> tag is an HTML element that is used in conjunction with the <map> element to define clickable areas within an image. These areas can be used as hyperlinks or to trigger specific actions when clicked. The most common use of the <area> tag is to create image maps, where different regions of an image are linked to different web pages or perform distinct functions.

In the below PDF we discuss about HTML Area Tag in detail in simple language, Hope this will help in better understanding.

HTM programming

Understanding the HTML <area> Tag:

Here’s a basic example of how the <area> tag is used within an HTML document:

<img src="image.jpg" alt="An example image" usemap="#imagemap">
<map name="imagemap">
<area shape="rect" coords="0,0,50,50" href="page1.html" alt="Area 1">
<area shape="circle" coords="100,100,50" href="page2.html" alt="Area 2">

In this example, an image is displayed, and two clickable areas are defined using the <area> tag within a <map>. The attributes of the <area> tag, such as shape, coords, and href, determine the shape, size, and destination of each clickable area.

Attributes of the <area> Tag:
The <area> tag has several attributes that allow you to define the characteristics of the clickable area. Here are the key attributes:

  1. shape: Specifies the shape of the clickable area. It can be one of the following values: rect (rectangle), circle (circle), poly (polygon), or default (the entire area not covered by other defined regions).
  2. coords: This attribute defines the coordinates of the clickable area. The format of the coordinates varies depending on the shape. For example, for a rectangle, you would provide the top-left and bottom-right coordinates as “x1, y1, x2, y2.”
  3. href: Indicates the URL or destination when the area is clicked. This can be an external link, an internal page, or even an email address.
  4. alt: Specifies alternative text for the area, which can be displayed when the image is not available or when the user hovers over the area.

use of area Tag:

  • Accessibility: Ensure that your image maps are accessible to all users. Provide descriptive alternative text for each area using the alt attribute.
  • Responsive design: Make your image maps responsive by specifying relative coordinates and sizes to adapt to different screen sizes.
  • Testing: Test your image maps thoroughly across various devices and browsers to ensure they function correctly.
  • Usability: Use image maps when they enhance user experience, such as in interactive diagrams or complex navigation menus. Avoid overusing them for simple links.
  • Documentation: Document your image maps to keep track of the clickable areas and their functions, making maintenance and updates easier.

Related Question

The <area> tag is used in conjunction with the <map> tag to define clickable areas within an image map. It is often used to create clickable regions in an image.

The <area> tag is used within a <map> element, where you define the shape, coordinates, and attributes of the clickable area.

Some best practices include providing clear and concise alt text for each <area> for accessibility, ensuring that clickable areas don’t overlap, and testing the image map across different browsers to ensure compatibility.

Yes, you can use multiple <map> elements on the same page, each associated with different images. This allows you to create multiple image maps with their own sets of clickable areas



Document Object Model (DOM) The

HTML Canvas Basics HTML Canvas

HTML Input Atrributes HTML input

HTML Event Attributes HTML event

HTML Global Attribute HTML global

HTML Attributes HTML attributes are

Leave a Comment

Your email address will not be published. Required fields are marked *

// Sticky ads