Published Jun 20, 2021Updated Jul 1, 2022
Contribute to Docs

The <img> element displays an image on the web page.


<img src="image URL" alt="text used for accessibility" />

The <img> element has no closing tag and it cannot have other tags inside of it. It uses attributes to set properties, some of which include:

  • src sets the URL or filename of images that support many formats (GIF, JPEG, PNG, etc.).`
  • alt is an alternative text used by screen readers and when the image does not load.
  • height is the height of the image, measured in pixels.
  • width is the width of the image, measured in pixels.


Below is an example of an image wrapped in an <a> element which creates an image link:

<head> </head>
<a href="https://codecademy.com">
alt="Codecademy Home Page"

This is what the rendered image look like:

Codecademy logo

All contributors

Looking to contribute?

Learn HTML on Codecademy