What is the <img>
Tag in HTML?
The <img>
tag is used to embed images in an HTML document.
Example:
<img src=”image.jpg” height=”500″ width=”500″>
Attributes of <img>
src :The source or path of the image (URL or file path)
alt : It is used to describe the Alternative text
Width and height : Controls image size in pixels or %
title : Text shown when hovering over the image
Image File Types You Can Use:
ile Type | Usage |
---|
.jpg / .jpeg |
Good for photos |
.png |
Good for transparent images |
.gif |
Good for simple animations |
.svg |
Good for logos and icons (scalable without losing quality) |
.webp |
Modern format, smaller size, good quality |