Skip to main content

News & Updates
๐Ÿ”“ Admissions Open! ๐Ÿ“ฐ New Branch Opened in Gulshan Ravi Lahore ๐Ÿ“ฐ New Branch Opened at Walton road Lahore ๐Ÿ”“ Admissions Open! ๐Ÿ“ฐ New Branch Opened at Ferozpur Road Lahore ๐Ÿ“ฐ New Branch Opened at PIA Road Lahore ๐Ÿ”“ Admissions Open!
HTML Fundamentals: Build Your First Web Page

Lesson

05. Images and Media

Images can explain, inform, and add visual interest. Correct HTML makes media responsive, understandable, and accessible.

Add an image

<img
  src="images/classroom.jpg"
  alt="Students learning web development in a classroom"
  width="1200"
  height="800"
>

The src attribute identifies the file. The alt attribute communicates the imageโ€™s purpose when it cannot be seen. Width and height help the browser reserve space before the image loads.

Use captions

<figure>
  <img src="images/code.jpg" alt="HTML code displayed in an editor">
  <figcaption>A simple HTML document in a code editor.</figcaption>
</figure>

Alt text guidelines

  • Describe information the image contributes.
  • Use alt="" for a purely decorative image.
  • Do not begin with โ€œimage ofโ€ unless the image type matters.
  • Keep important text as real text instead of placing it inside an image.

Practice activity

Create an images folder, add one relevant image, write useful alternative text, and place it inside a figure with a caption.

Knowledge check

Lesson quiz

Pass mark: 4/5