HTML – Images

  • HTML images are used to display images on the web page.
  • The <img> tag is a self-closing tag, meaning it doesn’t require a closing tag.

Example-

class-image

πŸš€ Try it yourself! Click the button below to run the code and see the output in action.

HTML Code

Output

In the above example –

  • src : attribute is used to mention the path of the image
  • alt : text is alternative text, which is displayed if the image cannot be loaded or for accessibility purposes.

So always try to use meaning image name in the alt text.

you can use height and width attributes also to define the height and width of the image.

Leave a Comment