HTML图像映射标签<area>
时间:2021-11-19 作者:匿名
定义和用法
<area> 标签定义图像映射中的区域(注:图像映射指得是带有可点击区域的图像)。
area 元素总是嵌套在 <map> 标签中,所以,需要搭配map一起使用。
注释:<img> 标签中的 usemap 属性与 map 元素 name 属性相关联,创建图像与映射之间的联系。
实例
带有可点击区域的图像映射:
<img src="图片.jpg" border="0" usemap="#mymap" alt="Planets" /> <map name="mymap" id="mymap"> <area shape="circle" coords="100,130,10" href ="1.html" alt="图形1名称" /> <area shape="circle" coords="120,160,10" href ="2.html" alt="图形2名称" /> <area shape="rect" coords="0,0,100,200" href ="3.html" alt="图形3名称" /> </map>
提示和注释:
注释:<img> 中的 usemap 属性可引用 <map> 中的 id 或 name 属性(由浏览器决定),所以我们需要同时向 <map> 添加 id 和 name 两个属性。
必需的属性
属性值描述
alttext定义此区域的替换文本。
其他可选属性
属性 | 值 | 描述 |
coords | 坐标值 | 定义可点击区域的坐标。 |
href | URL | 定义此区域的目标网址或锚点。 |
nohref | nohref | 从图像映射排除某个区域。 |
shape | default rect circ poly | 定义区域的形状。 |
target | _blank _parent _self _top | 规定在何处打开 href 属性指定的目标 URL。 |