搜索
首页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)heSdefinElayout,语义和互动性。2)SemantictagsiCtagSimproveCacsibilitieAndseo.3)pose poseriblesibilityAndseoandseo.3)poser

说明将一致的编码样式用于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

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版