Documentation

Student-friendly HTML, CSS, and JavaScript reference with examples

Sections

HTML Image Element

The <img> element displays images on your webpage. It’s a self-closing tag (no closing tag needed).

<img src="https://example.com/photo.jpg" alt="A beautiful sunset">

Required attributes:

  • src - The URL or path to the image file
  • alt - Description of the image (important for accessibility and if image fails to load)

Example with local image:

<img src="/images/logo.png" alt="Company logo">

Pro tip: Always include the alt attribute. It helps screen readers and shows if the image doesn’t load.