搜尋
首頁web前端html教學HTML 中的區域標記

HTML 中的區域標記

Sep 04, 2024 pm 04:31 PM
htmlhtml5HTML TutorialHTML PropertiesHTML tags

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

文法

基本文法如下:

<area alt="text" class=" " coords=" " shape> ;

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

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

對於圖像映射,語法是:

<img  src="/static/imghwm/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/imghwm/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/imghwm/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/imghwm/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/imghwm/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
HTML的目的:啟用Web瀏覽器可以顯示內容HTML的目的:啟用Web瀏覽器可以顯示內容May 03, 2025 am 12:03 AM

HTML的核心目的在於讓瀏覽器理解並展示網頁內容。 1.HTML通過標籤定義網頁結構和內容,如、到、等。 2.HTML5增強了多媒體支持,引入了和標籤。 3.HTML提供了表單元素,支持用戶交互。 4.優化HTML代碼可提升網頁性能,如減少HTTP請求和壓縮HTML。

為什麼HTML標籤對Web開發很重要?為什麼HTML標籤對Web開發很重要?May 02, 2025 am 12:03 AM

htmltagsareessentialforwebdevelopmentastheyandendenhancewebpages.1)semantictagsimproveaccessibilityandseo.2)semanteLayOut,語義和互動性。 3)poseriblesibilityandseoandseo.3)poseriblesoftagscanoftagscanoftagscanoptagscanoptimizeperefeneandimizeanDenSuroceRecRoscRoss-BrowserCrowserCercerComercompatibility。

說明將一致的編碼樣式用於HTML標籤和屬性的重要性。說明將一致的編碼樣式用於HTML標籤和屬性的重要性。May 01, 2025 am 12:01 AM

一致的HTML編碼風格很重要,因為它提高了代碼的可讀性、可維護性和效率。 1)使用小寫標籤和屬性,2)保持一致的縮進,3)選擇並堅持使用單引號或雙引號,4)避免在項目中混合使用不同風格,5)利用自動化工具如Prettier或ESLint來確保風格的一致性。

如何在 Bootstrap 4 中實現多項目輪播?如何在 Bootstrap 4 中實現多項目輪播?Apr 30, 2025 pm 03:24 PM

在Bootstrap4中實現多項目輪播的解決方案在Bootstrap4中實現多項目輪播並不是一件簡單的事情。雖然Bootstrap...

deepseek官網是如何實現鼠標滾動事件穿透效果的?deepseek官網是如何實現鼠標滾動事件穿透效果的?Apr 30, 2025 pm 03:21 PM

如何實現鼠標滾動事件穿透效果?在我們瀏覽網頁時,經常會遇到一些特別的交互設計。比如在deepseek官網上,�...

HTML 視頻的播放控件樣式怎麼修改HTML 視頻的播放控件樣式怎麼修改Apr 30, 2025 pm 03:18 PM

無法直接通過CSS修改HTML視頻的默認播放控件樣式。 1.使用JavaScript創建自定義控件。 2.通過CSS美化這些控件。 3.考慮兼容性、用戶體驗和性能,使用庫如Video.js或Plyr可簡化過程。

在手機上使用原生select會帶來哪些問題?在手機上使用原生select會帶來哪些問題?Apr 30, 2025 pm 03:15 PM

在手機上使用原生select的潛在問題在開發移動端應用時,我們常常會遇到選擇框的需求。通常情況下,開發者傾...

在手機上使用原生select的弊端是什麼?在手機上使用原生select的弊端是什麼?Apr 30, 2025 pm 03:12 PM

在手機上使用原生select的弊端是什麼?在移動設備上開發應用時,選擇合適的UI組件是非常重要的。許多開發者�...

See all articles

熱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

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

熱工具

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 Mac版

SublimeText3 Mac版

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