In HTML, the <img>
element is used to display images on a webpage. Images are an essential part of web design, providing visual context, enhancing information, and making websites more engaging for users.
Images are used in HTML to:
You can control the size of an image by setting the width
and height
attributes.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Images Page</title>
</head>
<body>
<img src="Birds.jpg" alt="Description of the image">
</body>
</html>
You can make an image clickable by wrapping it in an anchor (<a>
) tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Images Page</title>
</head>
<body>
<a href="https://aitaurangabad.com/"><img src="logo.png" alt="Clickable Image"></a>
</body>
</html>
You can apply a CSS hover effect to change the image style when hovered.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Images Page</title>
</head>
<body>
<style>
.hover-image:hover { opacity: 0.7; }
</style>
<img src="Rabit.jpg" alt="Hover Effect Image" class="hover-image">
</body>
</html>
Images in HTML enhance user engagement by providing visual context. By utilizing various image techniques, you can create visually appealing and functional webpages that enrich the user experience.