Sub topic 9
Images, Icons and Asset Quality
This chapter assumes you can open DevTools, read the Elements and Network panels, and know the CSS box model. You should also be comfortable with the earlier chapters on preparing a fair comparison and measuring with DevTools. Here you check the images, icons and other files that a page loads. Layout can match the design to the pixel while a blurry photo or a wrong icon still makes the page look wrong.
What to check on every asset
Assets fail in a small number of ways. Walk through the same list for each image or icon.
- Sharpness. The file has enough pixels for the size it is shown at, including on high-density screens.
- Crop and aspect ratio. The visible part of the image matches the design, and it is not stretched.
- Format and weight. The file type suits the content and the file is not needlessly large.
- Correct asset. The image or icon is the one in the design, not a placeholder or an older version.
- Color and size of icons. Icons match the design's size, stroke weight and color, and align with nearby text.
- Fallback behavior. Something sensible appears if the asset fails to load.
Sharpness and pixel density
A browser measures size in CSS pixels. A screen with a device pixel ratio (DPR) of 2 uses a 2×2 block of physical pixels for each CSS pixel. An image shown at 400 CSS pixels wide therefore needs about 800 pixels of real width to look sharp on that screen. At DPR 3 it needs about 1200.
The Elements panel can show you both numbers. Hover over an <img> tag and DevTools displays the rendered size and the intrinsic size, which is the file's own width and height. You can also read them from the console.
const img = document.querySelector('img.hero');
console.log({
renderedWidth: img.clientWidth,
naturalWidth: img.naturalWidth,
currentSrc: img.currentSrc,
devicePixelRatio: window.devicePixelRatio,
// Pixels per CSS pixel actually available:
effectiveDensity: (img.naturalWidth / img.clientWidth).toFixed(2)
});Compare effectiveDensity with devicePixelRatio. If density is 1.0 and the ratio is 2, the image is upscaled and will look soft. A density far above the ratio, such as 4 on a standard screen, means the page downloads more data than it needs.
Use currentSrc, not src. When the page uses srcset or a <picture> element, the browser chooses one file, and currentSrc tells you which one. Resize the window and read it again. The chosen file should change at the widths the developers intended.
Crop, aspect ratio and fit
Stretched or oddly cropped images are common. Compare the ratio of the rendered box with the ratio of the file. A photo that is 1600×900 shown in a 400×400 box must be cropped or letterboxed. The CSS property object-fit decides which.
| Value | Behavior | Typical result |
|---|---|---|
| `fill` (default) | Stretches to the box | Distorted image |
| `cover` | Scales to fill, crops the overflow | Full box, edges lost |
| `contain` | Scales to fit inside | Whole image, empty bars |
| `none` | Natural size, no scaling | Often cropped or too small |
If a face is cut off, object-position may need adjusting, for example object-position: 50% 20%. Check what the design shows. A design that crops to the subject's face should not be matched by a centered crop that shows the neck.
Also check that the layout does not jump while images load. An <img> with no width and height attributes, and no aspect-ratio in CSS, takes no space until it arrives. Throttle the network in DevTools to Slow 4G, reload, and watch whether the text below shifts down. That shift is a layout shift, and it counts as a visual defect.
Choosing the right format
The file type affects both quality and weight. Check the Network panel, filter by Img, and read the type and size columns.
| Content | Good format | Watch for |
|---|---|---|
| Photographs | WebP, AVIF, JPEG | Heavy compression artifacts, blocky skies |
| Logos, icons, simple shapes | SVG | Raster logos that blur when scaled |
| Screenshots, flat graphics with transparency | PNG, WebP | Huge PNGs of photos |
| Short animations | Video, animated WebP | Large GIF files |
Compression artifacts show up as blocks, smeared detail around text, or banding in gradients. Zoom the browser to 200% and look at edges and flat color areas. If the design file shows a smooth gradient and the page shows visible steps, the image is over-compressed or was exported with too few colors.
Icons
Icons come in three common forms: inline SVG, an SVG file loaded by <img> or CSS, and an icon font. Each has its own failure modes.
- Inline SVG takes its color from CSS when the fill is
currentColor. A wrong color usually means a hard-codedfillinside the file. - SVG as
<img>cannot inherit text color. If the design needs a hover color change, the developers need another approach. - Icon fonts fail by showing an empty square or a letter if the font file does not load. They also blur at fractional sizes.
Measure icons the way you measure text. Select the <svg> element and read its box in the Computed tab. Check the width, the height, and the stroke width. A 24-pixel icon in the design should be 24 pixels in the build, not 22 or 28. If icons of the same set differ in apparent weight, one may have been scaled while another was not, which changes the stroke thickness.
Check vertical alignment next to text. Icons that sit a pixel or two too high or low beside a label are a frequent defect. The outline snippet from the earlier chapter helps here, because it shows whether the icon box and the text box share a center line.
The console can list every SVG on the page with its size, which makes inconsistent icon sizes easy to spot.
const rows = [...document.querySelectorAll('svg')].map((svg) => {
const box = svg.getBoundingClientRect();
return {
width: Math.round(box.width),
height: Math.round(box.height),
fill: getComputedStyle(svg).fill,
label: svg.getAttribute('aria-label') || svg.closest('[aria-label]')?.getAttribute('aria-label') || ''
};
});
console.table(rows);Alt text and decorative assets
Visual QA is not an accessibility audit, but missing alternative text is cheap to catch while you are already looking at each image. A meaningful image needs a short alt description. A purely decorative one should have alt="" so screen readers skip it. Icons that stand alone as buttons need an accessible name, usually through aria-label. Note any image with no alt attribute at all, because that is different from an empty one.
Fallbacks and failure states
Assets fail in real use. Block a single image in the Network panel with the "Block request URL" option, or go offline, then reload. Look at what remains.
- Is there a background color that keeps text readable on top of a missing hero image?
- Does the broken-image icon appear, with the alt text spilling out of its box?
- Does an avatar fall back to initials or a default picture, as the design describes?
These checks connect to the later chapter on long text, empty states and missing images. Here, only note whether the design specifies a fallback and whether the build matches it.
Common mistakes in the QA itself
- Judging sharpness at the wrong zoom. Browser zoom changes the effective density. Reset to 100% before you decide an image is blurry.
- Trusting the design preview. A design tool may show an image at a higher resolution than the one developers were given. Ask for the exported assets.
- Comparing compressed screenshots. A JPEG screenshot adds its own artifacts. Capture PNG when you judge quality.
- Ignoring lazy loading. Images below the fold may not load until you scroll. Scroll through the whole page before you capture or measure.
Reporting asset problems
Give the developer evidence they can act on. For an asset defect, include the element selector, the currentSrc, the natural and rendered sizes, the device pixel ratio, and the browser. State what the design expects, for example "2x export at 800 px wide". A screenshot with the DevTools tooltip visible often supplies most of this in one image.
Exercise
A card image is displayed at 320 CSS pixels wide. On a screen with a device pixel ratio of 2, DevTools shows naturalWidth of 320. Is this a defect? What would you ask for, and what else would you check in the console before reporting?
Show answer
Yes, it is likely a defect. The screen needs about 640 pixels of image width (320 × 2), so the 320-pixel file is upscaled and will look soft. Ask for an export of at least 640 pixels wide, or a srcset that offers a 2x candidate. Before reporting, read currentSrc to confirm which file the browser chose, check that browser zoom is 100%, and confirm window.devicePixelRatio is 2. Also check whether srcset serves a larger file at other viewport widths.
Exercise
An icon in the build has the right size but stays black when the design shows it turning blue on hover. It is loaded with <img src="icon.svg">. Why can the hover color not be applied through the text color, and what would you report?
Show answer
An SVG loaded through <img> is rendered as a separate image and does not inherit CSS from the page, so color and currentColor have no effect on it. Report that the hover color is missing and note the loading method. Suggest inline SVG with fill="currentColor", a CSS mask, or a second colored file, and leave the choice to the developers.