Image aspect ratio

Images display at their intended proportions.

On this page

Impact

ScanGov impact ratings

About

Image aspect ratio is the relationship between an image's width and height. It's expressed as two numbers, like 16:9 or 4:3. For example, a 16:9 aspect ratio means the width is 16 units wide for every 9 units of height. Aspect ratio helps ensure images look good on different screens, like phones, computers, and TVs. Using the correct ratio prevents stretching or squishing the image and maintains its quality.

Why it's important

Ensures images display correctly without distortion on different screens and devices.

User stories

As a user, I want the website to display images at the correct aspect ratio so that I can read and interact with the content without distortion.

Code

Failing pattern:

<!-- Fail: explicit dimensions that distort the image -->
<img src="logo.png" width="300" height="50">

Passing pattern:

<!-- Pass: set one dimension and let the other scale -->
<img src="logo.png" width="300" height="auto">

<!-- Or in CSS -->
img { max-width: 100%; height: auto; }

Error

ScanGov messaging when a site fails a standard:

Image could not be displayed correctly due to aspect ratio issues.

Guidance

Indicators

On this page