html images explain deeply: 18 MCQs with answers

All 18 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 6 questions

Q1. Which statement best describes what an `<img>` tag actually contains?

Beginner
A A pointer that tells the browser where to fetch the image B A CSS rule that styles the image C A JavaScript object that loads the image D The image pixels stored inside the HTML file
Show answer & explanation

A pointer that tells the browser where to fetch the image

The `` tag does not store pixels. It is a placeholder that instructs the browser to fetch an external file and paint it in place. The actual image data lives in a separate file such as `.jpg` or `.png`.

Q2. A student writes `<img src="logo.png">` with no other attributes. Which attribute is missing that is required for accessibility?

Beginner
A `width` B `srcset` C `loading` D `alt`
Show answer & explanation

`alt`

`alt` is the alternative-text attribute required for accessibility. Without it, screen readers may read the filename aloud and users on broken connections see nothing useful.

Q3. Which of these is a void element with no closing tag?

Beginner
A `<span>` B `<img>` C `<p>` D `<div>`
Show answer & explanation

`<img>`

`` is a void element — it has no closing tag and cannot contain child content. The other three are container elements that wrap content.

Q4. A designer places a purely decorative divider image on a page. What should the `alt` attribute be?

Beginner
A `alt="decorative"` B `alt=""` (empty) C The `alt` attribute should be omitted entirely D `alt="divider image"`
Show answer & explanation

`alt=""` (empty)

An empty `alt=""` tells assistive technology to skip the image, which is correct for decoration. Omitting `alt` entirely is worse because screen readers may then read the filename aloud.

Q5. Which format is the best choice for a photograph on a product page?

Beginner
A SVG B GIF C JPEG D PNG
Show answer & explanation

JPEG

JPEG is designed for photographs, producing small files with millions of colours. SVG is for vectors, GIF is limited to 256 colours, and PNG produces larger files for photographic content.

Q6. `<img>` is a void element, so it has no closing tag and cannot contain child content.

Beginner
A True B False
Show answer & explanation

True

`` is a void element, so it has no closing tag and cannot contain child content.

Building up · 7 questions

Q7. A developer writes `<img src="hero.jpg" width="1200" height="600">`. What is the main benefit of including those HTML width and height attributes?

Intermediate
A The image file is automatically compressed B The browser reserves space early, preventing layout shift C The image loads before the surrounding text D The image becomes responsive on small screens
Show answer & explanation

The browser reserves space early, preventing layout shift

HTML `width` and `height` communicate the intrinsic aspect ratio so the browser can reserve the correct box before the file arrives. This prevents the text-jumping layout shift when the image finally loads.

Q8. A page has a large footer logo far below the fold. Which attribute should be added to defer its download?

Intermediate
A `decoding="async"` B `sizes="100vw"` C `fetchpriority="low"` D `loading="lazy"`
Show answer & explanation

`loading="lazy"`

`loading="lazy"` defers off-screen images until the user scrolls near them. This is one of the cheapest performance wins available in HTML.

Q9. A developer writes: ```html <img src="small.jpg" srcset="small.jpg 480w, medium.jpg 1024w, large.jpg 1920w" sizes="(max-width: 600px) 480px, 1024px" alt="Mountain landscape"> ``` What does the browser do with this markup?

Intermediate
A Ignores `srcset` and uses only `src` B Picks the smallest suitable file based on the `sizes` hint C Downloads all three files and displays the largest D Always downloads `small.jpg` regardless of screen
Show answer & explanation

Picks the smallest suitable file based on the `sizes` hint

The `w` descriptors declare each file's real pixel width, and `sizes` tells the browser how wide the image will render at each breakpoint. The browser then downloads only the file that fits, saving bandwidth.

Q10. Why is omitting the `alt` attribute worse than writing `alt=""`?

Intermediate
A Because search engines will not index the page B Because the image will not load without `alt` C Because the browser will show a broken-image icon D Because screen readers may read the filename aloud
Show answer & explanation

Because screen readers may read the filename aloud

An empty `alt=""` deliberately silences decoration. Omitting `alt` entirely leaves assistive tech to fall back on the filename, which is more confusing than silence.

Q11. A developer sets `<img src="a.jpg" width="500">` and assumes this is the same as CSS sizing. Why is this assumption wrong?

Intermediate
A HTML `width` only works on SVG images B HTML `width` sets the intrinsic aspect-ratio hint; CSS controls rendered size C HTML `width` overrides CSS and prevents responsiveness D HTML `width` is deprecated and does nothing
Show answer & explanation

HTML `width` sets the intrinsic aspect-ratio hint; CSS controls rendered size

The HTML `width` and `height` attributes tell the browser the intrinsic aspect ratio so it can reserve space early. CSS `width` and `height` control the rendered size. Best practice is to set both.

Q12. A news site serves crisp photos to retina phones without punishing desktop users. Which pair of attributes makes this possible?

Intermediate
A `srcset` and `sizes` B `alt` and `title` C `loading` and `decoding` D `width` and `height`
Show answer & explanation

`srcset` and `sizes`

`srcset` offers multiple files at different widths, and `sizes` tells the browser how wide the image will render at each breakpoint. Together they let the browser pick the right file for each device.

Q13. Which of these is NOT a reason `alt` text matters?

Intermediate
A Search engines use it as a content signal B It reduces the image file size on disk C Screen readers announce it in place of the image D It displays when the image fails to load
Show answer & explanation

It reduces the image file size on disk

`alt` serves accessibility, broken-image fallback, and SEO. It has no effect on the file size of the image itself — that is determined by the format and compression.

Topper level · 5 questions

Q14. A developer needs an icon that stays sharp at any zoom level and has a tiny file size. Which format fits best?

Advanced
A GIF B PNG C SVG D JPEG
Show answer & explanation

SVG

SVG is vector-based, so it scales infinitely without quality loss and produces very small files for icons and charts. Raster formats like JPEG, PNG, and GIF would blur or bloat at large sizes.

Q15. A team is choosing between a 2 MB PNG and a 150 KB JPEG for a photograph that will look identical either way. Which is the better choice for a performance-conscious page?

Advanced
A Either, because file size does not affect page speed B The PNG, because lossless quality always wins C The PNG, because it supports transparency D The JPEG, because it delivers the same look at a fraction of the bytes
Show answer & explanation

The JPEG, because it delivers the same look at a fraction of the bytes

Matching format to content is one of the highest-leverage performance decisions on a page. A 2 MB PNG photograph where a 150 KB JPEG looks identical is a real, common waste that slows the page.

Q16. A developer is deciding between `<img>` and CSS `background-image` for a product photo that customers should be able to right-click and save. Which is the better choice and why?

Advanced
A `background-image`, because it supports `srcset` B `<img>`, because it is real content that supports alt text and saving C `<img>`, because CSS backgrounds cannot display photographs D `background-image`, because it renders faster
Show answer & explanation

`<img>`, because it is real content that supports alt text and saving

Meaningful content belongs in ``, which supports `alt` text, right-click saving, and SEO value. CSS `background-image` is for decoration and often does not allow saving.

Q17. A developer is optimizing a webpage that includes multiple images. They want to ensure that images below the fold do not start downloading until they are about to be viewed. Which attribute should they use in their `<img>` tags to achieve this?

Advanced
A sizes='' B srcset='' C loading='lazy' D loading='eager'
Show answer & explanation

loading='lazy'

The correct option is `loading='lazy'`, which defers the loading of off-screen images until the user scrolls near them, improving page load performance.

Q18. A web developer is tasked with creating a responsive image solution for a product page. They want to ensure that the browser selects the most appropriate image size based on the device's screen width. They write the following code: ```html <img src='small.jpg' srcset='small.jpg 480w, medium.jpg 1024w, large.jpg 1920w' sizes='(max-width: 600px) 480px, 1024px' alt='Product image'> ``` What will happen if the browser's viewport is 500 pixels wide?

Advanced
A The browser will not display any image. B The browser will download 'large.jpg'. C The browser will download 'small.jpg'. D The browser will download 'medium.jpg'.
Show answer & explanation

The browser will download 'medium.jpg'.

The correct option is that the browser will download 'medium.jpg' because the viewport width of 500 pixels falls within the range specified in the `sizes` attribute, which indicates that the image should be displayed at 1024 pixels.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages