HTML <map> 属性 与 <area> 属性一起使用来定义一个图像映射(一个可点击的链接区域).
| 内容类别 | 流式内容,短语内容,palpable 内容。 |
|---|---|
| 允许的内容 | 任何透明元素。 |
| 标签省略 | 不允许,开始标签和结束标签都不能省略。 |
| 允许的父元素 | 任何接受短语内容的元素。 |
| DOM 接口 | HTMLMapElement |
属性
这个元素拥有全局属性。
name- name属性 给map一个名字用来查询,这个属性是必须的,值必须不能为空并且不能带空格。name属性不准与同文档中其他map元素的值相同,如果id属性也被添加,name属性和id属性的值必须相同。
示例
<map name="example-map-1"> <area shape="circle" coords="200,250,25" href="another.htm" /> <area shape="default" /> </map>
规范
| Specification | Status | Comment |
|---|---|---|
| HTML Living Standard <map> |
Living Standard | |
| HTML5 <map> |
Recommendation | |
| HTML 4.01 Specification <map> |
Recommendation | Initial definition |
浏览器兼容性
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 1.0 | 1.0 (1.7 or earlier)[1] 5.0 (5.0)[2] 17.0 (17.0)[3] |
(Yes) | 1.0 | 1.0 |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | 1.0 | 1.0 (1.0)[1] 5.0 (5.0)[2] 17.0 (17.0)[3] |
(Yes) | 1.0 | 1.0 |
[1] 从 Gecko 5.0 (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2) 起,空的映射不再略过,以支持兼容模式匹配时的非空映射。例如,考虑下面的 HTML:
<map></map> <map> <area shape="rect" coords="25,25,75,75" href="#fail"> </map> <img usemap="#a" src="image.png">
[2] Gecko 5.0 之前, <img> 元素会匹配第二个非空映射。现在它匹配第一个,即使它是空的。
[3] 从 Firefox 17 起, <map> HTML 元素的默认样式是 display: inline; 并且不再是 display: block;。这和其它浏览器行为一直,并且已经在兼容模式中这样做了。