Images have width/height attributes
mediumimages_dimensions
Checks that images have explicit width and height attributes.
What does this rule check?
Setting width and height attributes on images allows the browser to reserve the correct space before the image loads. This prevents layout shifts (CLS) that hurt Core Web Vitals scores.
Why is this important?
Without dimensions, the browser cannot reserve space for images, causing content to shift as images load. This creates a poor user experience and hurts your Core Web Vitals CLS score.
How to fix
Add width and height attributes to all <img> tags. Use CSS for responsive sizing. The browser uses these for aspect ratio calculation.
Examples
Incorrect
<img src="photo.jpg" alt="A landscape" />
Correct
<img src="photo.jpg" alt="A landscape" width="800" height="600" />
Agent fix snippet
Copy this snippet and paste it into your AI coding agent to fix this issue automatically.
Add width and height attributes to all images:
<img src="photo.jpg" alt="description" width="800" height="600" />
Use the image's intrinsic dimensions. CSS can still make it responsive.