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
nameattribute was deprecated for<area>elements in HTML5—it's no longer a valid attribute for this tag. Luckily, you already havealtandtitleattributes on each area that handle labeling for accessibility and user hover feedback, so we don't need thenameattribute at all. - The fix: Remove the
nameattribute from every<area>tag in your map.
2. "Element 'area' is missing required attribute 'alt'"
- What's going on: All
<area>elements require analtattribute for accessibility (screen readers use this to describe clickable areas to users with visual impairments). Your final<area>tag (the default one linking back toindex.htm) is missing this attribute. - The fix: Add a descriptive
altattribute to that last area. Something likealt="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
相关产品推荐
相关产品推荐

