10. Images
Images provide visual content for web pages, which helps improve the user experience and present information clearly. They can be photographs, graphics, icons, or illustrations.
HTML provides various elements for embedding, manipulating, and controlling images, which help enhance the aesthetics and functionality of a website. Understanding image tags, attributes, and responsive design principles is important for effective web development.
Syntax:
<img src="image_path" alt="Alternate
text for the image" width="200px" height="150px" />
- src: The
srcattribute sets the path (URL) of the image. - alt: The
altattribute sets the alternative text. If the image link is broken, the alternative text is shown on the web page instead. - width and height: The
widthandheightattributes set the width and height of the image.
10.1. Insert Images
You can embed an image into a web page using the <img> tag with the src attribute, which is the required attribute for setting the image path.
Note: The <img> tag is an empty tag, which means it contains only a list of attributes and has no closing tag.
Source Code:
<!DOCTYPE html>
<html>
<head>
<title>Image Example</title>
</head>
<body>
<h2>Example Image</h2>
<!-- Insert Image -->
<img src="images/logo/Kru_IT.png" alt="Kru_IT logo" width="200" height="150">
</body>
</html>Result:
Watch the video:



