srcset attributeimg tags correctly uses the srcset attribute to provide different image sizes for responsive loading?<img src="small.jpg" srcset="medium.jpg 600w, large.jpg 1200w" alt="Sample image">
The srcset attribute requires each image URL to be followed by a width descriptor (e.g., 600w) separated by commas. Option C uses the correct syntax. Option C misses width descriptors, C uses incorrect colon syntax, and A omits the 'w' unit.
sizes attributesizes attribute to specify that the image should be 100vw (full viewport width) on screens smaller than 600px and 50vw on larger screens?<img src="image.jpg" srcset="image-small.jpg 600w, image-large.jpg 1200w" sizes="(max-width: 600px) 100vw, 50vw" alt="Responsive image">
The sizes attribute syntax is: (media-condition) size, default-size. Option A correctly follows this format. Options A, B, and D use incorrect syntax with misplaced parentheses, colons, or arrows.
picture element with media queries<picture> <source media="(min-width: 800px)" srcset="large.jpg"> <source media="(min-width: 400px)" srcset="medium.jpg"> <img src="small.jpg" alt="Responsive image"> </picture>
The screen width is 500px. The first source requires at least 800px, so it does not match. The second source requires at least 400px, which matches 500px, so 'medium.jpg' is used. The img fallback is only used if no sources match.
img elements inside a section with class gallery to make them responsive with max-width 100% and height auto?img inside section with class gallery.Option D selects img elements inside a section with class gallery. Option D selects only direct child img of elements with class gallery, which may not be inside a section. Option D selects img inside any element with class gallery inside any section, which is different. Option D is invalid syntax.
picture element?<picture> <source media="(min-width: 800px)" srcset="large.jpg"> <source media="(min-width: 400px)" srcset="medium.jpg"> <img src="small.jpg" alt="A scenic mountain landscape at sunrise"> </picture>
The img element is the one rendered and accessible to screen readers. The source elements do not support alt attributes. Therefore, meaningful alt text should be provided only on the img tag. Options B, C, and D do not follow best accessibility practices.