上の絵は1つの画像の中に、四角形、円、五角形が書いてあるのですが、それぞれの図形をクリックすると次のページが表示されます。このように、図の一部をボタンとして使うことができます。
さて、上の例では次のように書きます。
<img src="click.gif" usemap="#map" border="0"> <map name="map"> <area shape="rect" coords="20,10,80,60" href="1.html"> <area shape="circle" coords="150,60,30" href="2.html"> <area shape="poly" coords="200,50,240,90,290,70,290,30,240,10" href="3.html"> <area shape="default" nohref> </map> |
一つずつ説明します。
<img src="click.gif" usemap="#map" border="0">
<map name="map"> : </map>
<area shape="rect" coords="20,10,80,60" href="1.html">
座標とは画像全体を点の集まりで捕らえたとき、左上から右方向と下方向に点いくつ分移動したかで、画像内の位置を表す数値です。右方向をX座標、下方向をY座標と呼びます。
<area shape="circle" coords="150,60,30" href="2.html">
<area shape="poly" coords="200,50,240,90,290,70,290,30,240,10" href="3.html">
<area shape="default" nohref>