You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HTML错误代码求助:area元素属性问题排查与修复

Fixing Your HTML Image Map Validation Errors

Hey there, let's work through fixing those validation errors for your Australia map image map! We'll break down each issue and apply simple fixes:

1. "Attribute 'name' not allowed on element 'area' at this point"

  • What's going on: The name attribute was deprecated for <area> elements in HTML5—it's no longer a valid attribute for this tag. Luckily, you already have alt and title attributes on each area that handle labeling for accessibility and user hover feedback, so we don't need the name attribute at all.
  • The fix: Remove the name attribute from every <area> tag in your map.

2. "Element 'area' is missing required attribute 'alt'"

  • What's going on: All <area> elements require an alt attribute for accessibility (screen readers use this to describe clickable areas to users with visual impairments). Your final <area> tag (the default one linking back to index.htm) is missing this attribute.
  • The fix: Add a descriptive alt attribute to that last area. Something like alt="Return to homepage" makes perfect sense here.

Corrected Full HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
<!-- Tutorial 2 Author: Logan Henson Date: 26 Jan 2018 -->
<meta charset = "utf-8" />
<script src="modernizr-2.js"></script>
<title>Australia Map</title>
</head>
<body>
<p>
<img src="images/australia_logo.jpg" alt="Australia logo" />
</p>
<p>
<img src="images/australia_map.jpg" alt="Map of Australia" usemap = "#australia_map"/>
</p>
<p>
<map name="australia_map">
<area shape="rect" coords="305,368,495,633" href="australia_states.htm#South%20Australia" alt="South Australia" title="South Australia" />
<area shape="rect" coords="17,113,296,569" href="australia_states.htm#Western%20Australia" alt="Western Australia" title="Western Australia" />
<area shape="rect" coords="302,58,459,363" href="australia_states.htm#Northern%20Territory" alt="Northern Territory" title="Northern Territory" />
<area shape="circle" coords="572,686,42" href="australia_states.htm#Tasmania" alt="Tasmania" title="Tasmania" />
<area shape="circle" coords="628,562,20" href="australia_states.htm#ACT" alt="Australia Capital Territory" title="Australia Capital Territory" />
<area shape="poly" coords="467,184,464,360,518,365,512,423,730,436,558,61" href="australia_states.htm#Queensland" alt="Queensland" title="Queensland" />
<area shape="poly" coords="508,428,722,439,652,558,625,532,598,567,500,516" href="australia_states.htm#NSW" alt="New South Wales" title="New South Wales" />
<area shape="poly" coords="501,522,497,605,641,614" href="australia_states.htm#Victoria" alt="Victoria" title="Victoria" />
<area shape="default" href="index.htm" alt="Return to homepage" />
</map>
</p>
</body>
</html>

After applying these changes, your HTML should pass validation checks without those errors!

内容的提问来源于stack exchange,提问作者UKWN

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:47:46