Image Tag IN HTML

The <img> tag in HTML is essential for displaying images on web pages. It's a self-closing tag, so it doesn't need a separate closing tag. Its primary attribute is src, specifying the image file's URL. The alt attribute provides alternative text for accessibility and when the image can't load. Optionally, attributes like width and height can adjust the image's dimensions on the page. It allows for various file formats like JPEG, PNG, or GIF. The <img> tag enhances user experience, making web content visually engaging and informative, crucial for conveying information effectively in today's multimedia-driven online environment.

  • Example :
  • Example-1
  • <!DOCTYPE html> <html> <body> <body> <h4>River</h4> <img src="river.jpeg" width="300" height="300"> </body> </body> </html>
    Output :

    River


    In this example,
    i.The <img> tag embeds an image.
    ii. The src attribute specifies the URL of the image.

  • Example-2
  • <!DOCTYPE html> <html> <head> <title></title> </head> <body> <h4>Cherry Blossm</h4> <img src="imgs/cherry blossm.jpeg" width="300" height="300"> </body> </html>
    Output :

    Cherry Blossm

  • Example-3
  • <!DOCTYPE html> <html> <head> </head> <body> <h4>flowers </h4> <img src="imgs/flowers.webp" width="300" height="200"> </body> </html> </html>
    Output :

    flowers


  • Conclusion :
  • In conclusion, the <img> tag in HTML serves as a fundamental element for incorporating images into web pages. Its simplicity and versatility make it essential for enhancing user experience, conveying information visually, and making content more engaging. By specifying attributes like src, alt, and optionally width and height, developers can ensure accessibility and proper display across various devices and browsers. As an integral part of modern web design, the <img> tag empowers creators to leverage the power of visual content effectively, enriching the online experience for audiences worldwide..