By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Images are fundamental to web design, enhancing user experience and conveying information visually. This topic covers HTML elements and attributes used to include and manage images on web pages: img, src, alt, width, height, figure, and figcaption. Mastering these elements is crucial for creating accessible, responsive, and visually appealing websites. Incorrect usage can lead to broken images, poor accessibility, and a subpar user experience. For instance, neglecting the alt attribute can make your website inaccessible to visually impaired users relying on screen readers.
<img src="image.jpg">
⚠️ Common pitfall: Forgetting the src attribute will result in a broken image.
Add Alternative Text
<img src="image.jpg" alt="A beautiful sunset">
⚠️ Common pitfall: Leaving the alt attribute empty or using irrelevant text.
Specify Image Dimensions
<img src="image.jpg" alt="A beautiful sunset" width="300" height="200">
⚠️ Common pitfall: Using incorrect dimensions can distort the image.
Group Images with Captions
html <figure> <img src="image.jpg" alt="A beautiful sunset"> <figcaption>A beautiful sunset over the mountains.</figcaption> </figure>
Experts view images as integral to both the visual and semantic structure of a web page. They prioritize accessibility and performance, using alt text thoughtfully and optimizing image dimensions. They also leverage figure and figcaption to enhance the semantic meaning and context of images.
Exam trap: Questions about accessibility will often focus on the alt attribute.
The mistake: Using incorrect image dimensions.
Exam trap: Questions about image rendering and layout issues.
The mistake: Not using figure and figcaption together.
Exam trap: Questions about semantic HTML and accessibility.
The mistake: Using irrelevant alt text.
Scenario: You are designing a blog post about travel destinations.Question: How would you include an image of a famous landmark with a caption? Solution:1. Use the img element with the src attribute pointing to the image file.2. Add a descriptive alt text.3. Wrap the image in a figure element and add a figcaption.Answer:
<figure> <img src="landmark.jpg" alt="The Eiffel Tower at sunset"> <figcaption>The Eiffel Tower at sunset in Paris, France.</figcaption> </figure>
Why it works: This structure ensures the image is accessible, semantically correct, and visually appealing with a caption.
Scenario: You need to optimize an image for a responsive design.Question: How would you specify the dimensions? Solution:1. Use the width and height attributes to define the image size.2. Confirm the dimensions match the actual image file.Answer:
<img src="responsive.jpg" alt="A responsive design example" width="400" height="300">
Why it works: Defining dimensions helps the browser allocate space, improving load performance and layout consistency.
<img src="image.jpg" alt="description" width="300" height="200">
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.