The <img> tag embeds images in web pages. It is a self-closing (void) element and must include at least a source and alternate text.
<img src="cat.jpg" alt="A cat sitting on a windowsill">The src points to the image file, while alt provides a textual description if the image fails to load or for screen readers.
src – Path or URL to the imagealt – Descriptive alternative text (crucial for accessibility and SEO)width and height – Control display size (e.g., pixels or %)title – Tooltip text shown on hoverloading="lazy" – Defers loading for performance (especially for images off-screen)<img src="photo.jpg" alt="Sample" width="200" height="150" loading="lazy">Images can be loaded using:
src="images/logo.png" (within your project)src="https://example.com/logo.png" (external file)alt textEmbed an image using the following criteria:
<img src="https://example.com/dog.jpg"
alt="Golden retriever running through a field"
width="300" height="200">
<style>
img {
max-width: 100%;
height: auto;
}
</style>Ask the AI if you need help understanding or want to dive deeper in any topic