HTMLhreflang 屬性


<area> 元素的 hreflang 屬性用於設定 area 中 url 的語言。以下是語法 −

<area hreflang="language_code">

其中,code 是針對該語言設定的 ISO 語言程式碼,例如,英文為 en,法文為 fr,日文為 js 等。

 現在,讓我們來看一個實現 <area> 元素的 hreflang 屬性的示例 −

示例

 線上試用

<!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" download="perl" hreflang="en"/>
   <area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial"
      href = "/html/index.htm" target = "_blank" download="html" hreflang="en"/>
   <area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial"
      href = "/php/index.htm" target = "_blank" download="php" hreflang="en"/>
</map>
</body>
</html>

輸出

在上面的示例中,我們對以下影像設定了對映 −

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

現在,我們已對其形狀設定了對映和 area −

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

我們使用 hreflang 設定了 url 的語言 −

hreflang="en"

上面,我們已針對英文設定。

更新於:2019 年 7 月 30 日

167 次瀏覽

開啟您的職業生涯

完成課程,獲得認證

開始
廣告