HTML <area> 标签
什么是<area> 标签?
<area> 标签定义图像映射内部的区域(图像映射指的是带有可点击区域的图像)。
<area> 元素始终嵌套在 <map> 标签内部。
注释: <img> 标签中的 usemap 属性与 <map> 元素中的 name 相关联,以创建图像与映射之间的关系。
浏览器支持
所有主流浏览器都支持 <area> 标签。
HTML 与 XHTML 之间的差异
在 HTML 中,<area> 没有结束标签。 在 XHTML 中,<area> 必须正确地关闭。
提示和注释:
注释:<img> 中的 usemap 属性可引用 <map> 中的 id 或 name 属性(由浏览器决定),所以我们需要同时向 <map> 添加 id 和 name 两个属性。
实例
带有可点击区域的图像映射:
<!DOCTYPE html>
<html lang='zh-cn'>
<head>
<meta charset="utf-8">
<title>HTML area 标签 xinbiancheng.cn</title>
</head>
<body>
<p>点击太阳或其他行星,注意变化:</p>
<img src="../i/planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" target="_blank" href="../jsref/sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" target="_blank" href="../jsref/mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" target="_blank" href="../jsref/venus.htm">
</map>
</body>
</html>
必需的属性
属性 | 值 | 描述 |
---|---|---|
alt | text | 定义此区域的替换文本。 |
可选的属性
属性 | 值 | 描述 |
---|---|---|
coords | 坐标值 | 定义可点击区域(对鼠标敏感的区域)的坐标。 |
href | URL | 定义此区域的目标 URL。 |
nohref | nohref | 从图像映射排除某个区域。 |
shape | default rect circ poly |
定义区域的形状。 |
target | _blank _parent _self _top |
规定在何处打开 href 属性指定的目标 URL。 |
全局属性
<area> 标签支持 HTML 中的全局属性。
事件属性
<area> 标签支持 HTML 中的事件属性。
相关文章
HTML DOM 参考手册: Area 对象