目錄
區域標籤在 HTML 中如何運作?
屬性
1.標籤特定屬性
2. Standard Attributes
3. Global Attributes
Examples to Implement Area Tags in HTML
Example #3
Conclusion
首頁 web前端 html教學 HTML 中的區域標記

HTML 中的區域標記

Sep 04, 2024 pm 04:31 PM
html html5 HTML Tutorial HTML Properties HTML tags

在這篇文章中,我們將學習 HTML 中的區域標籤。區域標籤定義圖像映射中的熱點並與超文本引用相關聯或連結以允許使用者在網頁上可點擊。它有助於在單擊地圖部分時連結不同的頁面。當圖像上需要多個連結時,標籤就變得很有用。

文法

基本文法如下:

<area alt="text" class=" " coords=" " shape> ;
登入後複製

這裡 alt 用於在圖像未渲染時替換文字。

  • class: 定義元素的類別名稱。
  • 座標:具有一組形狀值。

對於圖像映射,語法是:

<img  src="/static/imghw/default1.png" data-src="edu.jpg" class="lazy" html name alt="HTML 中的區域標記" >
<map name=" name">
<area shape="shapeName1" coords="x,y coordinates" href="html%20linkPath">
<area shape="shapeName2" coords=" x,y coordinates " href="htmllinkPath">
</map>
登入後複製

說明: 這是一個沒有結束標籤的空標籤,而在 XHTML 中,它被宣告為 。並且此區域標籤始終嵌入 。標籤(包含在地圖容器中),它給出特定圖像的座標值。而且,不活動區域也會發生重疊;透過優先激活較高區域來解決。以下部分透過範例介紹如何使用區域標籤以及瀏覽器相容性及其支援的屬性。

區域標籤在 HTML 中如何運作?

這是完成它的過程;最初是影像圖中的影像。

1.要將圖像插入頁面,我們應該使用下面給出的圖像標籤:

<img src="/static/imghw/default1.png" data-src="edu.jpg" class="lazy" alt="HTML 中的區域標記 logo"> // image from the saved folder. Also, we can get from the web URL directly and map with <map> tag.</map>
登入後複製

它帶有 src 屬性:描述圖像內容的來源和替代文字。

2. 其次,開啟有#map屬性的地圖元素。該圖像標籤帶有一個 use map,後面跟著“#”符號(use map =“#map”)。地圖名稱應與使用地圖的名稱相同。

如何建立影像映射?一起使用地圖和名稱屬性可以將圖像和地圖放在一起。當滑鼠遊標在螢幕上變成指標(手形符號)時,瀏覽器會辨識形狀的區域。

3.聲明要用於映射的區域。

<area shape="rect" cords='…….href="" ' alt="">
href comes with alt attribute by default.
登入後複製

屬性

一般來說,HTML 標籤具有一個或多個屬性,有助於向瀏覽器展示令人愉悅的視覺效果。使用三種屬性,即全域屬性、事件處理屬性和特定於元素的屬性。區域標籤提供標籤特定的屬性及其描述,如下所列,且 HTML 5 有一些新屬性。

1.標籤特定屬性

屬性名稱  描述                  範例
替代 在指定區域定義替代文本,以提高可訪問性。
href 定義超級引用意味著指向下一頁點/頁面 URL 的連結。它將一個區域更改為超連結。 document”
形狀  定義要在影像上完成的不同形狀。 ”第一文檔”

”第二份文件”

座標 給出適合影像中區域的特定值。座標指定如下:

預設:不需要電線。

長方形:左、上、右、下

圓:x、y、半徑

Poly: x1,y1, x2,y2,x3,y3…

document”
target Specifies where to open the link page, or I can say the end target page. ”
Nohref Defines that absence of href. This means the area doesn’t have a link to next page
type Specifies the content type (MIME) ”Authors
hreflang Specifies language-type ”Second

2. Standard Attributes

The description of these attributes has already been discussed in the previous article.

  • Access key
  • class
  • dir
  • id
  • Style
  • lang
  • id
  • tab index
  • title.

3. Global Attributes

  • onmouse down
  • onmouse up
  • onmouse over
  • onmouse move
  • onmouse out
  • on focus
  • on blur
  • onkey press
  • onkey down
  • onkey up.

Examples to Implement Area Tags in HTML

Below are examples of implementing area tags in HTML:

Example #1

In the below example, I have created a jpg image diary.jpg. When u execute the code, the hand tool moves over the image at the specified cords; when you click on it, it directs you to the page rr.html.

Code:



<img  src="/static/imghw/default1.png" data-src="diary.jpg" class="lazy" html alt="HTML 中的區域標記" >
<map name="Diary">
<area shape="rect" coords="94,91,189,193" href="rr.html">
</map>

登入後複製

Code: rr.html



hello

 Online tutorial Class
登入後複製
登入後複製

Output:

HTML 中的區域標記

Example #2

Code:



<img class="logo lazy" src="/static/imghw/default1.png" data-src="edu.jpg" alt="HTML 中的區域標記 logo"    style="max-width:90%"  style="max-width:90%" html>
<map name="ccmap">
<area shape="rect" coords="89,9,294,50" href="sha.html" alt="HTML 中的區域標記">
<area shape="rect" coords="297,7,407,54" href="rr.html" alt="Welcome">
</map>

登入後複製

Code: rr.html



hello

 Online tutorial Class
登入後複製
登入後複製

Code: sha.html



hello

 Welcome to the Page
登入後複製

Output:

HTML 中的區域標記

The Output below shows the logo of HTML 中的區域標記; clicking the word BA directs to the page Hello page.

HTML 中的區域標記

Example #3

Code:



<img src="/static/imghw/default1.png" data-src="new.png" class="lazy" alt="HTML 中的區域標記" border="0" html>
<map name="Protocols">
<area shape="Poly" coords="74,0,113,29,98,72,52,72,38,27" href="https://www.manageengine.com/network-monitoring/what-is-snmp.html%22" alt="SNMP Tutorial" target="_blank">
<area shape="rect" coords="22,83,126,125" alt="FTP Tutorial" href="https://www.techtarget.com/searchnetworking/definition/File-Transfer-Protocol-FTP" target="_blank">
<area shape="circle" coords="73,168,32" alt="http Tutorial" href="https://www.webopedia.com/TERM/H/HTTP.html" target="_blank">
</map>

登入後複製

Explanation of the above program: In this example, we have created an image map using the image file called new.png, which has three clickable areas declared within it using the tag. The first clickable area is a polygonal shape that links to the SNMP page called www.managengine.com. The second clickable area is a rectangular shape that links to the FTP page called www.searchnetworking.com, and finally, the last clickable area is a circle that links to an HTTP page called www.webopedia.com.

Output:

HTML 中的區域標記

Output:

HTML 中的區域標記

Conclusion

Therefore, we have seen how the area tag is used in active areas in switching to the pages with brief information explaining how to use the tag in clickable areas with syntax and demo examples.

以上是HTML 中的區域標記的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

HTML 中的表格邊框 HTML 中的表格邊框 Sep 04, 2024 pm 04:49 PM

HTML 表格邊框指南。在這裡,我們以 HTML 中的表格邊框為例,討論定義表格邊框的多種方法。

HTML 中的巢狀表 HTML 中的巢狀表 Sep 04, 2024 pm 04:49 PM

這是 HTML 中巢狀表的指南。這裡我們討論如何在表中建立表格以及對應的範例。

HTML 左邊距 HTML 左邊距 Sep 04, 2024 pm 04:48 PM

HTML 左邊距指南。在這裡,我們討論 HTML margin-left 的簡要概述及其範例及其程式碼實作。

HTML 表格佈局 HTML 表格佈局 Sep 04, 2024 pm 04:54 PM

HTML 表格佈局指南。在這裡,我們詳細討論 HTML 表格佈局的值以及範例和輸出。

HTML 輸入佔位符 HTML 輸入佔位符 Sep 04, 2024 pm 04:54 PM

HTML 輸入佔位符指南。在這裡,我們討論 HTML 輸入佔位符的範例以及程式碼和輸出。

HTML 有序列表 HTML 有序列表 Sep 04, 2024 pm 04:43 PM

HTML 有序列表指南。在這裡我們也分別討論了 HTML 有序列表和類型的介紹以及它們的範例

HTML onclick 按鈕 HTML onclick 按鈕 Sep 04, 2024 pm 04:49 PM

HTML onclick 按鈕指南。這裡我們分別討論它們的介紹、工作原理、範例以及各個事件中的onclick事件。

在 HTML 中移動文字 在 HTML 中移動文字 Sep 04, 2024 pm 04:45 PM

HTML 中的文字移動指南。在這裡我們討論一下marquee標籤如何使用語法和實作範例。

See all articles