Content · Web Development · HTML

HTML <img> Element: Adding Images to a Page

Img places a picture in a document. Src tells the browser which file to load, while alt describes the picture's useful information for people who cannot see it.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Img places a picture in a document. Src tells the browser which file to load, while alt describes the picture's useful information for people who cannot see it. Think about what the picture adds to the story, not just whether it looks nice on the screen.

What You Need to Know


The image file must actually exist at the path you write. Use a meaningful alt text for an informative photo, or alt="" for a purely decorative image.

Pictures can make a page much easier to understand, but they are useful only when the file loads and the important meaning is also available as text.

Example: See It in Action


Take a look at this small piece of HTML. You can use it in a practice document and change the text to make it your own.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<figure>
    <img src="images/turtle.jpg" alt="Green turtle swimming underwater">
    <figcaption>A turtle in the ocean.</figcaption>
</figure>

Let’s Understand the Example


  • Img displays an image. Src chooses the file and alt provides a useful text alternative.
  • Figure groups self-contained content, such as a photo or code illustration, with an optional caption.
  • Src tells the browser where to find an image or other embedded resource.
  • Alt supplies a text alternative for an image. Empty alt is appropriate for purely decorative images.

An image appears only if its file path is correct. If it is informative, its alt text should share the same useful meaning; if it is decoration, empty alt text is often right.

What Should You See?


If the image file is available, the picture appears in the page. If not, the browser may show a broken image or fallback text. The example alt text is “Green turtle swimming underwater”. Check that the text alternative fits the picture’s purpose.

Cover the picture and read the surrounding text aloud. If essential information has disappeared, add a useful text alternative or nearby explanation.

Try It Yourself


  1. Change the filename to a real image in your project and describe its content in alt.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Writing a correct-looking img tag but pointing src to a file that is not there.
  • Never guess at an image description. Write alternative text that matches the picture and its purpose on this page.

Key Takeaways


  • Img places a picture in a document.
  • Img displays an image. Src chooses the file and alt provides a useful text alternative.
  • The image file must actually exist at the path you write. Use a meaningful alt text for an informative photo, or alt="" for a purely decorative image.
Share this resourceSend this page to someone who may find it useful.