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

Boost your HTML and CSS skills with our Certification Test. Practice with multiple-choice questions and comprehensively designed quizzes. Prepare thoroughly for your certification exam with detailed explanations and insights!

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>

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy