<a> および <area> 要素の場合、href 属性は、リンク先のページの URL を指定します。
<base> 要素の場合、href 属性は、ページのすべての相対 URL のベース URL を指定します。
<link> 要素の場合、href 属性は、外部リソース(ほとんどの場合はスタイルシートファイル)の場所 (URL) を指定します。
href 属性は、以下の要素で使用することができます:
要素 | 属性 |
---|---|
<a> | href |
<area> | href |
<base> | href |
<link> | href |
クリック可能なエリアを持つイメージ・マップ:
<img src="planets.gif"
width="145" height="126"
alt="Planets"
usemap="#planetmap">
<map
name="planetmap">
<area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
<area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
<area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>
Try it Yourself ❯
ページ上のすべての相対 URL のベース URL を指定します:
<head>
<base href="http://www.w3schools.com/images/">
</head>
Try it Yourself ❯
href
属性は、要素ごとに以下のブラウザがサポートしています。
要素 | |||||
---|---|---|---|---|---|
a | Yes | Yes | Yes | Yes | Yes |
area | Yes | Yes | Yes | Yes | Yes |
base | Yes | Yes | Yes | Yes | Yes |
link | Yes | Yes | Yes | Yes | Yes |