Introduction to the use of html area image hotspots with a list of related properties

Introduction to the use of html area image hotspots with a list of related properties

The <area> tag is mainly used in image maps. It can be used to set an active area (also called a hotspot) in an image map. When the user moves the mouse to the specified active area and clicks it, it will automatically link to a pre-set page. Its basic grammatical structure is as follows:

<area class=type id=Value href=url alt=text shape=area-shape columns=value>

class and id: specify the type and id number of the hotspot respectively.

alt: Alternative text used to set the hotspot.

href: used to set the URL address to which the hotspot is linked.

Shape and coords: are the two main parameters used to set the shape and size of the hotspot. Its basic usage is as follows:

<area shape="rect" coords="x1, y1,x2,y2" href=url> means setting the shape of the hotspot to a rectangle, with the coordinates of the upper left corner vertex as (X1, y1) and the coordinates of the lower right corner vertex as (X2, y2).

<area shape="circle" coords="x1, y1,r" href=url> means setting the shape of the hotspot to a circle, with the center coordinates (X1, y1) and the radius r.

<area shape="poligon" coords="x1, y1,x2,y2 ......" href=url> means that the shape of the hotspot is set to a polygon, and the coordinates of each vertex are (X1, y1), (X2, y2), (x3, y3) ...... in sequence.

Note: The positions of the points x1, y1, x2, y2 are determined by the image, not the size of the window.

The <area> tag is used to divide the effective area in the image map, so the divided effective area must be within the area of ​​the image map. Therefore, before using the <area> tag to divide the area, you must use another HTML tag <map> to set the effective area of ​​the image map and set a name for the specified image map. The usage of this tag is very simple, that is, <map name="image map name">... </map>.

The following example illustrates the usage of these two tags:

Here is a picture of a new bookshelf. The desired effect is: when the mouse clicks on the book "URL Directory", a new window will open, displaying the book's introduction and order webpage (urlall.htm); when the mouse clicks on the book "Website Design Guide", a new window will open, displaying the book's introduction and order webpage (siteall.htm); when the mouse clicks on the book "Web Page Skills Encyclopedia", a new window will open, displaying the book's introduction and order webpage (pagejqlall.htm). Preparation method:

1. Insert the image and set the relevant parameters of the image. In the <img> tag, set the parameter usemap="newbook" ismap to indicate the reference to the image map (newbook);

2. Use the <map> tag to set the image map's area of ​​effect and name it: newbook;

3. Use the <area> tag to divide the three books into three rectangular areas, and set their link parameters href.

The production is completed. The source code of this example is as follows:

Copy code
The code is as follows:

<img src="upload/2022/web/logo.gif" width="207" height="148" alt="New Bookshelf" hspace="10" align="left" usemap="#newbook" border="0">
<map name="newbook">
<area shape="rect" coords="56,69,78,139" href="urlall.htm" target="_blank" alt="More than 100,000 URLs are collected here." title="More than 100,000 URLs are collected here."">
<area shape="rect" coords="82,70,103,136" href="siteall.htm" target="_blank" alt="Website Designer's Enlightenment Book." title="Website Designer's Enlightenment Book."">
<area shape="rect" coords="106,68,128,136" href="pageall.htm" target="_blank" alt="A book that web page makers must read." title="A book that web page makers must read."">
</map>

A few things to keep in mind when creating the effects described in this article:

1. Don’t forget to set the usemap and ismap parameters in the <img> tag, and the usemap parameter value must be the same as the name parameter value in the <map> tag, that is, the “image map name” must be consistent;

2. All hotspots in the same "image map" must be within the scope of the image map, that is, all <area> tags must be between <map> and </map>;

3. The coordinate format of the cords parameter in the <area> tag must match the shape of the action area set by the shape parameter to avoid the phenomenon that the coordinates of the vertices of the polygonal area are set in the rectangular action area set by the shape parameter.

Differences between HTML and XHTML

In HTML, the <area> element does not require a closing tag.

But in XHTML, the <area> element must be properly closed.

Required attributes

The DTD column indicates which document types support this attribute. S=Strict,T=Transitional,F=Frameset.

property value describe DTD
alt text Specify alternative text for a region STF

Optional attributes

property value describe DTD
coords coordinate Specify the coordinates of an area STF
href URL Specify a link target for a region STF
nohref nohref Indicates that there is no corresponding link in the area STF
shape default
rect
circle
poly
Specify the shape of the area STF
target _blank
_parent
_self
_top
Indicates where to open a new page TF

Core Attributes

The <area> tag supports the following core attributes:

property value describe DTD
accesskey character Set keyboard shortcuts for accessing elements STF
class Class Name Specifies the class name of the element STF
dir rtl
ltr
Specifies the text direction of the content in the element STF
id id Specifies the unique id of the element STF
lang Language Code Specifies the language code of the element's content STF
style Style Definition Specifies the inline style of an element STF
tabindex number Specifies the tab order of an element STF
title text Specifies the tooltip text of an element STF
xml:lang Language Code Specifies the language code for the content of an element in an XHTML document STF

More information about core properties.


Event attributes

The <area> tag supports the following event attributes:

property value describe DTD
onblur script Execute a script when an element loses focus STF
onclick script Execute the script when you click the mouse (regardless of left or right button) in the element area STF
ondblclick script Execute the script when you double-click the mouse in the element area (regardless of left and right buttons) STF
onfocus script Execute a script when an element gains focus STF
onmousedown script Execute the script when the mouse button is pressed in the element area (regardless of left or right button) STF
onmousemove script Execute a script when the mouse pointer moves within the element area STF
onmouseout script Execute a script when the mouse pointer moves out of the element area STF
onmouseover script Execute a script when the mouse pointer enters the element area STF
onmouseup script Execute the script when you release the mouse button (regardless of left or right button) in the element area STF
onkeydown script Execute a script when a key is pressed STF
onkeypress script Execute a script when a key is pressed and released STF
onkeyup script Execute a script when a key is released STF

<<:  Notes on matching MySql 8.0 and corresponding driver packages

>>:  Solution to prevent caching in pages

Recommend

How to recover accidentally deleted table data in MySQL (must read)

If there is a backup, it is very simple. You only...

A brief analysis of the count tracking of a request in nginx

First, let me explain the application method. The...

CentOS6.8 Chinese/English environment switching tutorial diagram

1. Introduction People who are not used to Englis...

Vue uses the method in the reference library with source code

The official source code of monaco-editor-vue is ...

Docker link realizes container interconnection

Table of contents 1.1. Network access between con...

Docker /var/lib/docker/aufs/mnt directory cleaning method

The company's service uses docker, and the di...

Detailed explanation of the syntax and process of executing MySQL transactions

Abstract: MySQL provides a variety of storage eng...

MySQL 8.0 New Features - Introduction to the Use of Management Port

Table of contents Preface Connection Management A...

Thinking about grid design of web pages

<br />Original address: http://andymao.com/a...

How to connect idea to docker to achieve one-click deployment

1. Modify the docker configuration file and open ...

CSS3 realizes the mask barrage function

Recently I saw a barrage effect on B station call...

Implementation example of react project from new creation to deployment

Start a new project This article mainly records t...

React implements the expansion and collapse function of complex search forms

Give time time and let the past go. In the previo...

Detailed explanation of Vue filter implementation and application scenarios

1. Brief Introduction Vue.js allows you to define...