<img> Tag in HTML
The <img> tag in HTML is used to embed images into a webpage. It is an inline element, meaning it does not create line breaks in the document. The <img> tag requires at least one attribute: src, which defines the source (location) of the image file. Additionally, it is recommended to use the alt attribute to provide alternative text for the image if it cannot be displayed.
Key Points on <img> Tag:
- The <img> tag is self-closing, meaning it does not require a closing tag.
- The src attribute is used to specify the path to the image file.
- The alt attribute provides a description of the image, which is useful for accessibility and when the image cannot be loaded.
- Attributes like width and height can be used to control the size of the image.
Syntax of <img> Tag:
Syntax Example
<img src="image_path" alt="description" width="500" height="400">
Example of <img> Tag in HTML:
This example demonstrates how to use the <img> tag to display an image sourced from the LBSNAA website.
Code Example
<img src="B1.jpg" alt="Sample Image" width="50%" height="30%">
Output
 }})
The <img> tag is widely used for embedding images into websites, whether for logos, photos, or other content. Always provide an alt attribute to ensure better accessibility and SEO.