Image Height and Width Required
ID |
html.height_width_required |
Severity |
low |
Remediation Complexity |
low |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Html |
Tags |
reliability |
Rationale
When the intrinsic dimensions of an image are known up front, the browser can reserve the exact layout box before the image loads. Without them, content reflows once the image arrives, producing Cumulative Layout Shift that hurts perceived performance and the page’s Core Web Vitals.
<img src="a.png" alt="x"> <!-- FLAW — no dimensions -->
<img src="a.png" alt="x" width="100"> <!-- FLAW — height missing -->
<img src="a.png" alt="x" width="100" height="50"> <!-- OK — both declared -->
Remediation
Add width and height attributes matching the image’s intrinsic aspect ratio. Use CSS
(for example height: auto) if the rendered size must be responsive while still reserving space.