Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
Ans:
The <img> tag is used to insert an image into a webpage.
Yes, the <img> tag is an empty tag, meaning it does not need a closing tag like </img>.
The 'src' (source) and 'alt' (alternative text) attributes are mandatory in the <img> tag.
The 'src' attribute specifies the path of the image file to be displayed.
<img src="flower.jpg" alt="Beautiful Flower" />
By using an absolute URL in the 'src' attribute, such as
<img src="https://example.com/image.jpg" alt="Example Image" />
The 'alt' attribute provides a text description for the image, useful when the image cannot be loaded and for screen readers used by visually impaired users.
The text from the 'alt' attribute will be displayed in place of the image.
By using the 'width' and 'height' attributes in the
<img> tag, e.g., <img src="dog.jpg" alt="Cute Dog" width="200" height="150" />
The browser automatically adjusts the other dimension to keep the image's proportions correct.
The 'title' attribute.
<img src="book.jpg" alt="Book Image" title="This is a Book" />
The 'border' attribute was used in older HTML; now, it is preferred to use CSS (e.g., style="border:2px solid black;").
<img src="pen.jpg" alt="Pen" style="border:2px solid black;" />
The 'align' attribute was used to align images with the text (left, right, middle), but it is not recommended now; CSS should be used instead.
<img src="car.jpg" alt="Car" align="left" />
It displays the image file named 'nature.jpg' with alternative text 'Nature Image' if the image cannot be shown.
By giving values like width="50%" and/or height="50%" in the <img> tag.
You should avoid using the old 'border' and 'align' attributes because modern HTML uses CSS for styling and alignment.