Images specify width and height to prevent layout shift
Why it matters
Images without explicit width and height attributes cause Cumulative Layout Shift (CLS), one of three Core Web Vitals metrics. When a browser downloads an image and discovers its dimensions, it reflows surrounding content — shifting text and buttons mid-read. Google's CWV assessment penalizes pages with CLS above 0.1, and users who experience unexpected layout shifts are significantly more likely to abandon a page. This is a direct business impact: form submissions and purchase buttons that shift away from the user's tap are missed conversions.
Severity rationale
High because Cumulative Layout Shift caused by dimensionless images is a Core Web Vitals failure that directly harms search ranking and user retention.
Remediation
Add width and height attributes to every <img> tag, or use aspect-ratio CSS on the container. For dynamically sized images, aspect-ratio preserves space without hardcoding pixel values. The Next.js Image component requires these attributes and handles the reservation automatically.
// Before — layout shifts when image loads
<img src="/team.jpg" alt="Team" />
// After — space reserved before image loads
<img src="/team.jpg" alt="Team" width={800} height={600} />
// CSS aspect-ratio for fluid-width images
<div style={{ aspectRatio: '16/9', width: '100%' }}>
<img src="/team.jpg" alt="Team" style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
</div>
// Next.js Image (enforces dimensions)
import Image from 'next/image'
<Image src="/team.jpg" alt="Team" width={800} height={600} />
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Performance & Load Readiness Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · performance-efficiency.resource-utilization — Resource Utilization
Taxons
History
- 2026-04-18·v1.0.0·Initial import from performance-load·automated