Programmingempire
This article describes about Creating Image Map in HTML. Basically, an image map allows to create clickable areas within an image.
Sometimes we want that different parts of an image represent certain actions. In other words, when we click on a specific part of an image some specific action occurs. Hence, the image has some clickable regions. The purpose of an image map is to create the clickable regions within an image.
In order to create the clickable regions on an image, we need to use the <map> element along with the image. Therefore, in the <img> tag, we specify the usemap attribute. Similarly, in the <map> tag, we need to specify the name attribute with the same value as that of the usemap value. The following example demonstrates it.
<html>
<head>
<title>
Image Map Example
</title>
</head>
<body>
<img src="img1.jpg" alt="Sunset" usemap="#pmap"/>
<map name="pmap">
<area shape="rect" coords="20, 100, 90, 56" alt="programmingempire" href="https://www.programmingempire.com/"/>
<area shape="circle" coords="300, 225, 50" alt="princites" href="https://princites.com/"/>
</map>
</body>
</html>
Within the map element we can specify the clickable areas. For this purpose, we use the <area> tag. The <area> tag has three important attributes – shape, coords, and href. The following list specifies the possible values of the shape attribute.
- rect
- circle
- poly
In fact, the value of the coords attribute relates with the value of the shape attribute. When the shape is rect, the coords attribute takes four values separated by the comma. These four values represent the x, any coordinates of the top-left, and bottom-right corners of the rectangle respectively. When the shape is circle, the coords attribute has three values representing the x, and y coordinates of the center, and the length of radius respectively.
In order to create the polygon region, the shape attribute should be set to the value poly. Also. the coords attribute should specify any number of pairs of x, and y coordinates representing the coordinates of different points of the polygon.
Output
Further Reading
Example of Column Properties in CSS
Examples of Outline Properties in CSS
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Data Visualization
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- ES6
- Extended Reality
- Flutter and Dart
- Full Stack Development
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- Tkinter
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML