Skip to main content
Checks for width/height attributes (prevents CLS)
Rule IDimages/dimensions
CategoryImages
ScopePer-page
Severitywarning
Weight4/10

Solution

Specifying width and height attributes prevents Cumulative Layout Shift (CLS) by reserving space before images load. Add width and height attributes to img tags matching the image’s intrinsic dimensions. Use CSS for responsive sizing if needed. For responsive images, the aspect ratio from width/height prevents layout shifts even when CSS overrides the actual size.

Enable / Disable

Disable this rule

squirrel.toml
[rules]
disable = ["images/dimensions"]

Disable all Images rules

squirrel.toml
[rules]
disable = ["images/*"]

Enable only this rule

squirrel.toml
[rules]
enable = ["images/dimensions"]
disable = ["*"]