HTML Guides for area
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The target attribute on the <area> element tells the browser where to display the linked resource — in the current tab, a new tab, a parent frame, or a named <iframe>. According to the WHATWG HTML living standard, a valid navigable target must be either a keyword beginning with an underscore (_self, _blank, _parent, _top) or a name that is at least one character long. An empty string ("") satisfies neither condition, so the W3C validator reports:
Bad value "" for attribute "target" on element "area": Browsing context name must be at least one character long.
This commonly happens when templating engines or CMS platforms output target="" as a default, or when a value is conditionally set but the logic fails to produce a result.
Why this matters
- Standards compliance. An empty
targetviolates the HTML specification and produces a validation error. - Unpredictable browser behavior. While most browsers treat an empty
targetthe same as_self, this is not guaranteed by the spec. Relying on undefined behavior can lead to inconsistencies across browsers or future versions. - Code clarity. An empty
targetsignals unclear intent. Removing it or using an explicit keyword makes the code easier to understand and maintain.
How to fix it
- Remove the
targetattribute if you want the link to open in the same browsing context. This is the default behavior, equivalent totarget="_self". - Use a valid keyword like
_self,_blank,_parent, or_topif you need specific navigation behavior. - Use a named browsing context (e.g.,
target="contentFrame") if you want to direct the link to a specific<iframe>or window. The name must be at least one character long. - Fix your template logic if the empty value is being generated dynamically. Ensure the
targetattribute is only rendered when a non-empty value is available.
Examples
Invalid: empty target attribute
This triggers the validation error because target is set to an empty string:
<imgsrc="floor-plan.png"usemap="#rooms"alt="Floor plan">
<mapname="rooms">
<areashape="rect"coords="10,10,100,60"href="/kitchen"alt="Kitchen"target="">
</map>
Fixed: remove target for default behavior
If you want the link to open in the same tab (the default), simply remove the target attribute:
<imgsrc="floor-plan.png"usemap="#rooms"alt="Floor plan">
<mapname="rooms">
<areashape="rect"coords="10,10,100,60"href="/kitchen"alt="Kitchen">
</map>
Fixed: use a valid keyword
Use _self to be explicit about same-tab navigation, or _blank to open in a new tab:
<imgsrc="floor-plan.png"usemap="#rooms"alt="Floor plan">
<mapname="rooms">
<areashape="rect"coords="10,10,100,60"href="/kitchen"alt="Kitchen"target="_self">
<areashape="rect"coords="110,10,200,60"href="/bedroom"alt="Bedroom"target="_blank">
</map>
Fixed: target a named <iframe>
If you want to load the linked resource into a specific <iframe>, give the <iframe> a name attribute and reference it in target:
<iframename="detailView"src="about:blank"title="Room details"></iframe>
<imgsrc="floor-plan.png"usemap="#rooms"alt="Floor plan">
<mapname="rooms">
<areashape="rect"coords="10,10,100,60"href="/kitchen"alt="Kitchen"target="detailView">
</map>
Fixed: conditionally render target in templates
If your target value comes from a variable, make sure the attribute is only output when the value is non-empty. For example, in a Jinja-style template:
<areashape="rect"coords="10,10,100,60"href="/kitchen"alt="Kitchen"
{%iftarget_value%}target="{{ target_value }}"{%endif%}>
This prevents target="" from appearing in your HTML when no value is set.
The shape attribute on an <area> element tells the browser what kind of clickable region to define within an image map. The HTML living standard (WHATWG) strictly limits this attribute to four values:
rect— a rectangle, defined by four coordinates:x1,y1,x2,y2(top-left and bottom-right corners)circle— a circle, defined by three values:x,y,r(center point and radius)poly— a polygon, defined by a series ofx,ycoordinate pairs tracing the shape's verticesdefault— the entire image area (nocoordsneeded)
The value "polygon" is a common mistake — it's intuitive and used in other contexts like SVG — but it is not valid HTML. Browsers may silently fall back to default or ignore the region entirely when they encounter an unrecognized shape value, which means users could lose the ability to click that area of the image map.
Why this matters
- Browser compatibility: Browsers are not required to handle invalid
shapevalues gracefully. While some may guess your intent, others may render the clickable region incorrectly or not at all. - Accessibility: Screen readers and assistive technologies rely on valid markup to convey image map regions to users. An invalid
shapevalue can make a region invisible to these tools, breaking keyboard navigation and alternative text announcements. - Standards compliance: Using valid attribute values ensures your markup behaves predictably across all browsers and passes automated validation checks.
How to fix it
Replace shape="polygon" with shape="poly". The coords attribute syntax stays the same — a comma-separated list of x,y pairs representing each vertex of the polygon, in order. Coordinate values are in CSS pixels relative to the image's intrinsic (natural) dimensions.
Also ensure that each <area> element includes:
- An
hrefattribute to make the region a link - An
altattribute for accessibility (required whenhrefis present)
Examples
Invalid: using shape="polygon"
<imgsrc="plan.png"usemap="#floormap"alt="Floor plan"width="400"height="300">
<mapname="floormap">
<areashape="polygon"coords="10,10,80,10,80,60,10,60"href="room-a.html"alt="Room A">
</map>
The validator reports: Bad value "polygon" for attribute "shape" on element "area".
Fixed: using shape="poly"
<imgsrc="plan.png"usemap="#floormap"alt="Floor plan"width="400"height="300">
<mapname="floormap">
<areashape="poly"coords="10,10,80,10,80,60,10,60"href="room-a.html"alt="Room A">
</map>
Changing "polygon" to "poly" resolves the error. The four coordinate pairs (10,10, 80,10, 80,60, 10,60) define a rectangular polygon. The browser automatically closes the shape by connecting the last point back to the first.
Reference: all valid shape values
<imgsrc="diagram.png"usemap="#shapes"alt="Shape examples"width="500"height="400">
<mapname="shapes">
<!-- Rectangle: top-left (10,10) to bottom-right (100,80) -->
<areashape="rect"coords="10,10,100,80"href="rect.html"alt="Rectangle region">
<!-- Circle: center (200,60), radius 40 -->
<areashape="circle"coords="200,60,40"href="circle.html"alt="Circle region">
<!-- Polygon: triangle with three vertices -->
<areashape="poly"coords="350,10,400,80,300,80"href="triangle.html"alt="Triangle region">
<!-- Default: covers any area not claimed by other regions -->
<areashape="default"href="elsewhere.html"alt="Everything else">
</map>
This example demonstrates all four valid shape values with their corresponding coords syntax. Note that default does not require a coords attribute since it covers the remainder of the image.
The <area> element defines a clickable region within an <map> element, which is used with images to create image maps. When an <area> element includes an href attribute, the browser treats it as a hyperlink. The value of href must be a valid URL, and http:// alone fails validation because the URL specification requires a host after the :// separator. An empty host is not permitted.
This matters for several reasons. Browsers may handle malformed URLs unpredictably — some might ignore the link, others might attempt navigation to a nonsensical destination, and others might throw a network error. Screen readers and other assistive technologies rely on valid href values to announce links correctly and provide meaningful navigation to users. From a standards compliance perspective, the WHATWG URL Standard explicitly rejects URLs with empty hosts, and the W3C validator flags this as an error.
This issue commonly appears when placeholder URLs are left in during development, when CMS tools generate incomplete markup, or when a URL value is dynamically constructed but the host portion ends up empty.
How to fix it
- If the area should link somewhere, replace
http://with the full, intended URL including the host (e.g.,https://example.com/page). - If the area is a temporary placeholder, use
href="#"to create a valid no-op link, though be aware this will scroll the page to the top when clicked. - If the area shouldn't be interactive, remove the
hrefattribute entirely. Withouthref, the<area>element is not a hyperlink and won't be clickable.
Examples
Invalid: empty host in URL
The value http:// has no host, which triggers the validation error.
<imgsrc="diagram.png"alt="Site map"usemap="#siteMap">
<mapname="siteMap">
<areashape="rect"coords="30,23,183,191"href="http://"alt="Home page">
</map>
Fixed: complete URL with a valid host
Providing a full URL with a host resolves the error.
<imgsrc="diagram.png"alt="Site map"usemap="#siteMap">
<mapname="siteMap">
<areashape="rect"coords="30,23,183,191"href="https://example.com/"alt="Home page">
</map>
Fixed: placeholder link with #
If you need the area to remain clickable but don't have a destination yet, href="#" is a valid placeholder.
<imgsrc="diagram.png"alt="Site map"usemap="#siteMap">
<mapname="siteMap">
<areashape="rect"coords="30,23,183,191"href="#"alt="Home page">
</map>
Fixed: non-interactive area without href
If the area doesn't need to be a link, simply omit the href attribute.
<imgsrc="diagram.png"alt="Site map"usemap="#siteMap">
<mapname="siteMap">
<areashape="rect"coords="30,23,183,191"alt="Home page">
</map>
The <area> element defines a clickable region within an image map (<map>). The coords attribute works together with the shape attribute to describe the geometry of that region. When the coordinates don't conform to the rules for the given shape, the browser may ignore the area entirely or interpret it unpredictably, making the clickable region inaccessible to users.
Each shape type has strict requirements:
- Rectangle (
shape="rect"): Requires exactly four integers in the formatx1,y1,x2,y2, wherex1,y1is the top-left corner andx2,y2is the bottom-right corner. Because0,0is the top-left of the image,x1must be less thanx2andy1must be less thany2. - Circle (
shape="circle"): Requires exactly three integers in the formatx,y,r, wherex,yis the center of the circle andris the radius. The radius must be a positive integer, and the first coordinate (the x-center) must be less than the third value (the radius) is not required—but the validator message mentions this constraint to flag cases where values appear swapped or malformed. - Polygon (
shape="poly"): Requires at least six integers (threex,ycoordinate pairs), forming a polygon with at least three vertices (a triangle). The format isx1,y1,x2,y2,...,xn,yn, and the number of integers must be even since they represent pairs.
Getting these formats wrong is a standards compliance issue. Assistive technologies such as screen readers rely on valid <area> definitions to convey interactive regions to users. Invalid coordinates can also cause the clickable area to silently fail in some browsers.
Examples
Invalid: Rectangle with swapped coordinates
The top-left corner values are larger than the bottom-right corner values:
<mapname="nav">
<areashape="rect"coords="200,150,50,10"href="/home"alt="Home">
</map>
Fixed: Rectangle with correct coordinate order
<mapname="nav">
<areashape="rect"coords="50,10,200,150"href="/home"alt="Home">
</map>
Invalid: Circle with wrong number of values
Four values are provided instead of the required three:
<mapname="nav">
<areashape="circle"coords="100,75,50,25"href="/info"alt="Info">
</map>
Fixed: Circle with three values
<mapname="nav">
<areashape="circle"coords="100,75,50"href="/info"alt="Info">
</map>
Invalid: Polygon with too few coordinates
Only four integers (two coordinate pairs) are provided, but a polygon needs at least three pairs:
<mapname="nav">
<areashape="poly"coords="10,20,30,40"href="/about"alt="About">
</map>
Fixed: Polygon with at least three coordinate pairs
<mapname="nav">
<areashape="poly"coords="10,20,30,40,20,60"href="/about"alt="About">
</map>
Invalid: Non-integer or malformed values
Decimal numbers and spaces in the wrong places will also trigger this error:
<mapname="nav">
<areashape="rect"coords="10.5, 20, 100, 200"href="/page"alt="Page">
</map>
Fixed: Using only comma-separated integers
<mapname="nav">
<areashape="rect"coords="10,20,100,200"href="/page"alt="Page">
</map>
Complete valid image map example
<imgsrc="floorplan.png"alt="Office floor plan"usemap="#office">
<mapname="office">
<areashape="rect"coords="0,0,150,100"href="/lobby"alt="Lobby">
<areashape="circle"coords="200,150,40"href="/meeting-room"alt="Meeting room">
<areashape="poly"coords="300,50,400,50,400,150,350,200,300,150"href="/lounge"alt="Lounge">
</map>
When debugging coordinate issues, double-check that the shape attribute matches the number of coordinates you've provided, that all values are non-negative integers separated by commas with no extra spaces, and that rectangle corners are specified in the correct top-left to bottom-right order.
In older versions of HTML, the <a> element supported a shape attribute (with values like rect, circle, poly, and default) to define clickable hotspot regions within an image map. This feature was removed from the HTML specification, and the shape attribute is now considered obsolete on <a> elements.
The modern and correct way to create image maps is to use the <map> element containing one or more <area> elements. Each <area> element accepts a shape attribute along with coords to define clickable regions, and an href to specify the link destination. The <img> element is then associated with the map via its usemap attribute.
Why this matters
- Standards compliance: The
shapeattribute on<a>is not part of the current HTML living standard. Using it produces a validation error and relies on deprecated behavior that browsers are not required to support. - Browser compatibility: Modern browsers implement image maps through
<map>and<area>. Using the obsolete<a shape="...">syntax may not work reliably across browsers. - Accessibility: The
<area>element is designed to work with assistive technologies in the context of image maps. It supports thealtattribute, which provides text alternatives for each clickable region — something essential for screen reader users.
How to fix it
- Remove the
shapeattribute from any<a>elements. - Create a
<map>element with a uniquenameattribute. - Inside the
<map>, add<area>elements with the appropriateshape,coords,href, andaltattributes. - Associate the map with an
<img>element using theusemapattribute, referencing the map'snamewith a#prefix.
Examples
Incorrect: using shape on an <a> element
<imgsrc="workspace.png"usemap="#workspace"alt="Workspace diagram"width="400"height="300">
<mapname="workspace">
<ashape="rect"coords="0,0,200,150"href="/monitor.html">Monitor</a>
<ashape="circle"coords="300,200,50"href="/lamp.html">Desk lamp</a>
</map>
This triggers the validation error because the shape attribute is obsolete on <a> elements.
Correct: using <area> elements instead
<imgsrc="workspace.png"usemap="#workspace"alt="Workspace diagram"width="400"height="300">
<mapname="workspace">
<areashape="rect"coords="0,0,200,150"href="/monitor.html"alt="Monitor">
<areashape="circle"coords="300,200,50"href="/lamp.html"alt="Desk lamp">
</map>
Each <area> element defines a clickable region with shape and coords, links to a destination with href, and provides an accessible label with alt. The <area> element is a void element (no closing tag needed), and the alt attribute is required when href is present.
Supported shape values on <area>
| Value | Description | coords format |
|---|---|---|
rect | A rectangle | x1,y1,x2,y2 |
circle | A circle | centerX,centerY,radius |
poly | A polygon defined by multiple points | x1,y1,x2,y2,...,xn,yn |
default | The entire image area not covered by other shapes | No coords needed |
Example with multiple shape types
<imgsrc="floorplan.png"usemap="#floorplan"alt="Office floor plan"width="600"height="400">
<mapname="floorplan">
<areashape="rect"coords="10,10,200,150"href="/conference-room.html"alt="Conference room">
<areashape="circle"coords="400,300,60"href="/break-room.html"alt="Break room">
<areashape="poly"coords="300,10,350,80,250,80"href="/lobby.html"alt="Lobby">
<areashape="default"href="/office-overview.html"alt="General office area">
</map>
This example demonstrates all four shape types working together in a single image map, with proper alt text for each clickable region.
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
Pro Trial
Full Pro access. Cancel anytime.
Start Pro Trial →Join teams across 40+ countries