The HTML <area> Element

Publish in HTML Tutorial el 23/05/2025 15:47

The <area> element defines a clickable area inside an image map (an image with clickable areas). It is always nested inside a <map> tag. The element is invisible to users but creates hyperlinked regions on an image that can be circles, rectangles, or polygons.


Key attributes include:

  • shape: Defines the shape of the area (rect, circle, poly, default)
  • coords: Specifies coordinates of the area
  • href: The hyperlink target
  • alt: Alternative text for accessibility
  • target: Where to open the linked document


Basic Syntax


Examples


1. Basic Image Map with Rectangular Area

This example creates a rectangular clickable area on an image.

Play Code


2. Circular Clickable Area

This example creates a circular clickable region.

Play Code


3. Polygonal Area with Multiple Points

This example creates a complex polygonal clickable area.

Play Code


4. Area with JavaScript onClick Event

This example shows how to use JavaScript with the area element.

Play Code


5. Multiple Areas with JavaScript Hover Effects

This example demonstrates multiple areas with hover effects using JavaScript.

Play Code


Tips and Tricks

  • Use image editing software with rulers to accurately determine coordinates for your areas
  • Always include alt text for accessibility
  • For complex shapes, break them down into simpler polygons
  • Consider using CSS tooltips with JavaScript for better hover effects
  • Test your image maps on different devices as coordinate precision is important


Browser Support

The <area> element is supported by all major browsers. However, complex image maps may not work well on mobile devices due to the precision required for touching small areas.

También te puede interesar

HTML <style> Element
HTML <style> Element

The <style> HTML element contains style information for a document, or part of a document. ...

HTML <strong> Element
HTML <strong> Element

The <strong> element is used to indicate that its content has strong importance, seriousnes...

HTML <span> Element
HTML <span> Element

The <span> element is an inline container used to mark up a part of a text or document. Unl...

HTML <source> Element
HTML <source> Element

The <source> element is used to specify multiple media resources for media elements like &l...

HTML <small> Element
HTML <small> Element

The <small> element is used to represent side-comments and small print, typically for discl...

HTML <section> Element
HTML <section> Element

HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...