The img Element

Embedding Photos onto Your Web Pages

We'll cover the following

Images #

Use the <img> tag to embed an image into your web page with an src attribute that contains a file path to the image you want to be included. Use the alt attribute to provide alternative text with a description of the image in case it doesn’t load, or is being read by a screen reader for people with disabilities.

Unlike most of the elements we have encountered thus far, the img element does not have a closing tag :

<!-- Incorrect img declaration -->
<img src="path/to/image/cat.jpg" alt="A cat"></img>

<!-- Correct img declaration -->
<img src="path/to/image/cat.jpg" alt="A cat">

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy