HTML area hreflang 属性
htmlweb developmentfront end technology更新于 2025/6/23 0:44:17
<area> 元素的 hreflang 属性用于设置区域中 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"/>
现在,我们已经为形状设置了地图及其内部区域 −
<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"
以上,我们已设置为英语。
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

