HTML <area> Tag

We’re talking about Tag Area. I believe this will fulfill the requirements for learning.

Syntax

<area shape="" coords="" href="">

The following image map has clickable areas:

Example

<!DOCTYPE html> <html> <body><img src="https://mrexamples.com/wp-content/uploads/html_images/workplace.jpg" alt="Workplace" usemap="#workmap" width="500" height="290"> <map name="mrxmap"> <area shape="rect" coords="34,44,270,350" alt="Computer" href="mrxcomp.htm"> <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm"> <area shape="circle" coords="337,300,44" alt="Black coffee cup" href="blackcoffee.htm"> </map></body> </html>

In the Tag Area, here is our second image map that includes clickable areas:

Example

<!DOCTYPE html> <html> <body><img src="https://mrexamples.com/wp-content/uploads/2023/03/outerspace-58.gif" width="300" height="225" alt="earth" usemap="#universemap"><map name="universemap"><area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun"><area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury"><area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus"> </map></body> </html>

Here is an example of the tag <area> with the svg:

Example: 

<!DOCTYPE html> <html> <body> <svg width="300" height="200"> <rect x="10" y="10" width="50" height="50" onclick="location.href='http://example.com/rectangle';"></rect> <circle cx="100" cy="100" r="40" onclick="location.href='http://example.com/circle';"></circle> <polygon points="200,10 250,190 160,210" onclick="location.href='http://example.com/polygon';"></polygon> </svg> </body> </html>


Uses and Definition

The Tag Area <area> represents an area within an image map (an image map consists of clickable areas).

Generally, <area> elements are nested within the <map> tag.

IMPORTANT: In specific images, the use map attribute in <img> is linked with the element’s name attribute of the map element, establishing a connection between the image and the map.


Advantages of HTML <area> tag

The HTML <area> tag is used to define a clickable area within an image map. Here are some advantages of using this tag:

  1. By using the <area> tag, you can accurately map out specific areas within an image, making it easier for users to click on the exact spot they want.
  2. With image maps and the <area> tag, you can make it easier for users to navigate through your website, as they can click on specific areas of an image to access different pages or information.
  3. Using image maps and the <area> tag can make your website more accessible to visually impaired users who rely on screen readers. The tags provide a way to add alternative text to the images, which can be read aloud to users.
  4. By using image maps and the <area> tag, you can reduce the overall load time of your website by combining multiple images into one. This can improve the speed of your website and make it more efficient.

In a nutshell, with the <area> tag, you can create more complex and creative designs, as you can use images as links and map out multiple clickable areas within them.


Global Attributes

In HTML, the <area> tag accepts Global Attributes as well.


Event Attributes

In HTML, the <area> tag accepts Event Attributes as well.


Attributes

AttributeValueOverview
hreflanglanguage_codeThis parameter defines the destination URL’s language.
referrerpolicyno-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin-when-cross-origin
unsafe-url
Indicate which referrer details to include in the link.
alttextProvides an alternative text for the area. Must be present if the href attribute is included.
shapedefault
rect
circle
poly
Describe the area’s shape
coordscoordinatesA description of the area’s coordinates.
downloadfilenameThis indicates that the user who clicks on the hyperlink will download the target.
hrefURLThis parameter defines the target hyperlink for the area.
mediamedia queryProvides details about which media/device the URL is optimized for.
target_blank
_parent
_self
_top
framename
Decide on the opening location for the target URL
relalternate
author
bookmark
help
license
next
nofollow
noreferrer
prefetch
prev
search
tag
Describes the relationship between the present document and the target URL
typemedia_typeThe type of media associated with the target URL is determined

Browser Compatibility

Element
<area>YesYesYesYesYes


CSS Settings By Default

The majority of browsers will show the <area> element with the following values by default in Tag Area:

area {
display: none;
}

Do subscribe to our Newsletter below, if you want to be in touch with the latest technical information on this site.
We value your feedback.
+1
1
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

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