Expat Diaries: Black Americans in Asia
This code snippet represents a series of <source> tags within an <picture> element (though the <picture> tag itself is missing). It’s designed for responsive images, meaning the browser will choose the best image source based on the viewport width. Let’s break down what’s happening and identify some issues:
What it’s trying to do:
The code aims to provide different image sources (and sizes) depending on the screen size. the srcset attribute specifies the image URLs and their corresponding pixel densities (1x and 2x, indicating standard and high-resolution images for retina displays). The media attribute defines the conditions (viewport width) under wich each source should be used.
Problems and Redundancies:
- Repetitive and Incorrect
srcset: The vast majority of the<source>tags are identical. They all point to the same image (https://www.essence.com/wp-content/uploads/2025/10/Sha-Cannon-Dragon-Bridge-over-Han-River-Da-Nang-Vietnam-scaled.jpg) with the same 1x and 2x options. This defeats the purpose of responsive images. You want different images for different screen sizes, ideally optimized for those sizes.
- Incorrect Media Queries: The
mediaattributes are mostly nonsensical.min-width: 4x3px, min-width: 1x1px,min-width: 3x2px, min-width: 2x3px,min-width: 136x91px, andmin-width: nonepxare not valid or useful media query values. Media queries should use standard units likepx, em,rem, or viewport units likevwandvh.noneis also not a valid value formin-width.
- Missing
<picture>Tag: the code is incomplete. All these<source>tags must be enclosed within a <picture>tag. There also needs to be an<img>tag inside the<picture>tag as a fallback for browsers that don’t support<picture>.
- Inconsistent Use of
width: The last few<source> tags do use thewidthparameter in the srcset(e.g.,?width=800). This is a better approach, but it’s inconsistent with the rest of the code. Usingwidthis generally preferred over pixel density (1x, 2x) because it allows the browser to choose the best image size based on the viewport.
- Future date in URL: The URL includes “2025/10”. This suggests the image hasn’t been published yet, or the date is incorrect.
Corrected and Simplified Example:
Here’s a much more reasonable example of how to use <picture> for responsive images:
“`html
