HTML 5 <area> 标签

定义和用法

<area> 标签定义图像映射中的区域。

HTML 4.01 与 HTML 5 之间的差异

HTML 5 有一些新的属性,且不再支持 HTML 4.01 的一些属性。

例子:

<img src ="planets.gif" alt="Planets" usemap ="#planetmap" />

<map id ="planetmap">
 <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>

属性

属性 描述 4 5
alt

定义此区域的替换文本。如果 href 存在,则该属性是必需的。

仅在 href 属性存在时使用。

4 5
coords 定义可点击区域的坐标。 4 5
href 定义此区域的目标 URL。 4 5
hreflang 规定目标 URL 的基准语言。仅在 href 属性存在时使用。 4 5
nohref 不赞成。从图像映射排除一个区域。 4  
media 规定目标 URL 的媒介类型。默认值:all。仅在 href 属性存在时使用。   5
ping

由空格分隔的 URL 列表,当用户点击该链接时,这些 URL 会获得通知。

仅在 href 属性存在时使用。

  5
rel 规定当前文档与目标 URL 之间的关系。仅在 href 属性存在时使用。   5
shape 规定区域的形状。 4 5
target 在何处打开目标 URL。 4 5
type 规定目标 URL 的 MIME 类型。仅在 href 属性存在时使用。   5

标准属性

class, contenteditable, contextmenu, dir, draggable, id, irrelevant, 
lang, ref, registrationmark, tabindex, template, title

如需完整的描述,请访 HTML 5 中标准属性

事件属性

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, 
ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, 
ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, 
onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, 
onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

如需完整的描述,请访 HTML 5 中事件属性

TIY

创建图像映射
本例显示如何创建带有可供点击区域的图像映射。其中的每个区域都是一个超级链接。