Image Tag in HTML



 


the <img> tag in HTML is used to embed images in a webpage. It is a self-closing tag, meaning it does not require a closing tag. Here’s the basic syntax and explanation:

Syntax:

<img src="url" alt="description" width="value" height="value">

Attributes:

1. src: (Required) The URL of the image file. This can be a relative path or an absolute URL.
o Example: src="image.jpg" or src="https://example.com/image.jpg"

2. alt: (Required for accessibility) A textual description of the image, displayed if the image cannot
be loaded. This is also used by screen readers for accessibility.
o Example: alt="A description of the image"

3. width: (Optional) Specifies the width of the image in pixels or as a percentage.
o Example: width="300" or width="50%"

4. height: (Optional) Specifies the height of the image in pixels or as a percentage.
o Example: height="200" or height="50%"


Post a Comment

0 Comments