How to use image tag in HTML?

Query By: ARNAB PRAJAKTA

B

Bright Madhu

Image or <img> Tag in HTML

The <img> tag is a self-closing tag that is used to display an image on a webpage. And when we used the <img> tag, it requires the src attribute, which specifies the URL or file path of the image to be displayed


Syntax Example of Image Tag in HTML

<img src="image.jpg" alt="Image description" />


List of Attributes Used with <img> Tag

src

  • The src attribute specifies the source URL or file path of the image.
  • It can be a relative path or an absolute URL.

alt

  • The alt attribute provides alternative text for the image.
  • It is used by screen readers or in cases where the image cannot be displayed.
  • It is important for accessibility and should describe the content or purpose of the image.

width and height: 

  • width and height attributes specify the width and height of the image in pixels.
  • They are optional but can be used to set the initial dimensions of the image, which can help with page layout and improve performance by reserving space for the image.

title

  • The title attribute provides additional information or a tooltip that is displayed when the user hovers over the image.


Syntax Example of all Attributes

<img src="images/image.jpg" alt="Beautiful Cat" width="800" height="600" title="Cat is enjoying on Garden" />

1 votes

Your Answer

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

LifeStyle & Fun

© 2024 GDATAMART.COM (All Rights Reserved)