HTMLhref 屬性


HTML <area> 元素的 href 屬性設定了超連結目標。以下是語法 −

<area href="URL">

上方,URL 是您需要為區域指定的超連結,該區域可以是相對連結、絕對連結、指令碼、協議等。

現在我們將瞭解一個示例來實現 HTML <area> 元素的 href 屬性 −

示例

 線上演示

<!DOCTYPE html>
<html>
<body>
<h2>Learning</h2>
<p>Learn these technologies with ease....</p>
<img src = /images/usemap.gif alt = "usemap" border = "0" usemap = "#tutorials"/>
<map name = "tutorials">
   <area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27"
      href = "/perl/index.htm" alt = "Perl Tutorial" target = "_blank" />
   <area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial"
      href = "/html/index.htm" target = "_blank" />
   <area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial"
      href = "/php/index.htm" target = "_blank" />
</map>
</body>
</html>

輸出

在上面的示例中,我們已經設定了以下影像上的地圖 −

<img src = /images/usemap.gif alt = "usemap" border = "0" usemap = "#tutorials"/>

現在,我們已對該地圖及其中區域進行設定,以使之具有形狀 −

<map name = "tutorials">
   <area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27"
      href = "/perl/index.htm" alt = "Perl Tutorial" target = "_blank" />
   <area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial"
      href = "/html/index.htm" target = "_blank" />
   <area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial"
      href = "/php/index.htm" target = "_blank" />
</map>

以上區域的超連結是使用 href 屬性進行設定的 −

href = "/php/index.htm

更新於: 30-7-2019

139 次瀏覽

開啟你的 職業生涯

完成課程即可獲得認證

開始學習
廣告
© . All rights reserved.