HTML and CSS Certification Practice Test

Question: 1 / 400

Which HTML tag would you use to include an image that adapts to different screen sizes?

<img src="SmallLogo.png">

<source src="source.jpg">

<picture><source srcset="NormalLogo.png" media="(min-width: 768px)"><img src="SmallLogo.png"></picture>

Using the `<picture>` element with the `<source>` and `<img>` tags allows for responsive image handling in HTML. This structure is particularly effective for adapting images to varying screen sizes and resolutions.

In the correct option, the `<picture>` element serves as a container that identifies different versions of the same image based on media queries defined in the `<source>` tags. The `srcset` attribute in the `<source>` tag specifies which image file to use based on the conditions set by the `media` attribute. In this case, if the screen width is at least 768 pixels, the browser will select "NormalLogo.png." If the conditions are not met (like on smaller screens), the `<img>` tag serves as a fallback, displaying "SmallLogo.png."

This technique enhances loading performance and visual quality by ensuring the appropriate image is served to the user based on their device, improving the overall user experience.

Other options do not offer the same adaptive capabilities. The `<img>` tag on its own cannot respond to screen sizes in the same way that the `<picture>` element can, and the `<source>` tag typically pertains to media elements like `<audio>` or `<video>`, not images. The use of `<image>`

Get further explanation with Examzify DeepDiveBeta

<image src="ResponsiveLogo.png">

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy