HTML Image Tag

  • Purpose: To insert an image into an HTML document.
  • Tags: <img>
  • Attributes
    • src: Specifies the URL or path to the image file.
    • Alt: Provides an alternative text description for the image, which is displayed if the image cannot be loaded or for users with screen readers.
    • width: Sets the width of the image in pixels or as a percentage.
    • height: Sets the height of the image in pixels or as a percentage.
  • Example:
<img src="image.jpg" alt="A beautiful landscape" width="300" height="200"> 

This code will display an image named “image.jpg” with a width of 300 pixels and a height of 200 pixels. If the image cannot be loaded, the text “A beautiful landscape” will be displayed instead.

Scroll to Top