Problem Statement
Which tag is used to display images in HTML?
Explanation
The img tag is used to display images in HTML. It is a self-closing tag, which means it does not need a closing tag. The img tag requires two essential attributes to work properly. The src attribute specifies the source or path to the image file. The alt attribute provides alternative text that describes the image. Without these attributes, the image will not display correctly or will be inaccessible to users with disabilities. The img tag is one of the most commonly used elements in web development. It can display various image formats including JPEG, PNG, GIF, SVG, and WebP. Understanding how to properly use the img tag is fundamental for creating visual web content.
Code Solution
SolutionRead Only
<!-- Basic image --> <img src="photo.jpg" alt="A beautiful sunset"> <!-- Image with path --> <img src="images/logo.png" alt="Company Logo"> <!-- Image with absolute URL --> <img src="https://example.com/image.jpg" alt="Description">
