How do you insert an image into HTML?

Use the <img> tag. It is an empty element, so it has no closing tag. Two attributes are needed: src (the path of the image) and alt (a short text description).

<img src="images/photo.jpg" alt="A boy playing cricket" width="300" height="200">
  • src can be a relative path like images/photo.jpg or a full URL.
  • alt is shown when the image cannot load, and read by screen readers.
  • width and height set the size in pixels.

See HTML Images.


Learn more about the similar topics:
Tutorials
HTML Links
HTML Images
Exercises & Assignments
Write an HTML program to create links (new tab and email)
Write an HTML program to display an image
Interview Questions & Answers
How do you create links to sections within the same page?
What do you mean by HTML links?
How to create a link to jump to a specific part of a page in HTML?
How do you insert an image into HTML?
What is the alt attribute in HTML and why is it important?
How to open a link in a new tab in HTML?
What is the difference between absolute and relative URL in HTML?