HTML 5 <area> 标签

定义和用法

<area> 标签定义图像映射内部的区域(图像映射指的是带有可点击区域的图像)。

area 元素始终嵌套在 <map> 标签内部。

注释:<img> 标签中的 usemap 属性与 map 元素中的 name 相关联,以创建图像与映射之间的关系。

实例

带有可点击区域的图像映射:

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

<map id="planetmap">
 <area shape ="rect" coords ="0,0,110,260" href ="sun.htm" alt="Sun" />
 <area shape ="circle" coords ="129,161,10" href ="mercur.htm" alt="Mercury" />
 <area shape ="circle" coords ="180,139,14" href ="venus.htm" alt="Venus" />
</map>

亲自试一试

浏览器支持

所有主流浏览器都支持 <area> 标签。

HTML 4.01 与 HTML 5 之间的差异

HTML5 提供了一些新属性,同时不再支持 HTML 4.01 中的某些属性。

属性

属性 描述
alt text 规定区域的替代文本。如果使用 href 属性,则该属性是必需的。
coords coordinates 规定区域的坐标。
href URL 规定区域的目标 URL。
hreflang language_code 规定目标 URL 的语言。
media media query 规定目标 URL 是为何种媒介/设备优化的。默认:all。
nohref nohref HTML 5 中不支持。
rel
  • alternate
  • author
  • bookmark
  • external
  • help
  • license
  • next
  • nofollow
  • noreferrer
  • prefetch
  • prev
  • search
  • sidebar
  • tag
规定当前文档与目标 URL 之间的关系。
shape
  • rect
  • rectangle
  • circ
  • circle
  • poly
  • polygon
规定区域的形状。
target
  • _blank
  • _parent
  • _self
  • _top
  • framename
规定在何处打开目标 URL。
type mime_type 规定目标 URL 的 MIME 类型。

全局属性

<area> 标签支持 HTML 5 中的全局属性

事件属性

<area> 标签支持 HTML 5 中的事件属性