How to Add an Image to HTML?

To add an image to an HTML document, follow these steps:

  1. First, save the image file in a location that is accessible to your HTML file, such as in the same folder or in a subfolder.
  2. Use the <img> tag to insert the image into your HTML file. The <img> tag is a self-closing tag and does not require a closing tag.
  3. In the <img> tag, specify the src attribute and set its value to the file path or URL of the image file.
  4. You can also include other attributes such as alt and title to provide additional information about the image for accessibility and SEO purposes.

Here is an example of how to insert an image into an HTML file:


<!DOCTYPE html>
<title>Adding an Image to HTML</title>
<h1>My Image</h1>
<img src=”path/to/my-image.jpg” alt=”A beautiful landscape” title=”My favorite place to go hiking”>


In this example, the image file “my-image.jpg” is located in the “path/to” folder. The alt attribute describes the image for users who cannot see it, and the title attribute provides additional information about the image when the user hovers over it.