# Fix stretched figures caused by conflicting dimensions

Canonical: https://githtml.com/guides/image-stretched-css-aspect-ratio
Published: 2026-11-23
Publisher: WaveTech LLC / gitHtml

A stretched figure usually has incompatible width and height constraints or a mismatched aspect ratio. Compare the intrinsic image dimensions with HTML attributes and CSS rules. Preserve the original proportions unless distortion is intentional, and verify the image itself before assuming every geometric difference is a stylesheet problem.

## Identify the specific failure

An export can specify correct dimensions in markup and then override one axis with a fixed CSS value. A chart's circles become ovals, making the visual encoding unreliable. This is especially problematic when readers infer relative size from the figure.

## Make a narrow correction

Remove conflicting constraints and use automatic sizing for the dependent dimension. Aspect-ratio can reserve space, but it should reflect the intended geometry. Do not repair a distorted source image by adding an opposite distortion that only works at one viewport.

1. Record the image's intrinsic dimensions and compare them with its styled dimensions.
2. Remove fixed constraints that force a different ratio unintentionally.
3. Recheck geometry at multiple widths rather than only matching one screenshot.

````text
img.figure { max-width: 100%; height: auto; }
````

## Locate the constraint that changes the figure's geometry

Suppose a chart is intrinsically 900 by 600 pixels, but the page gives it width: 100% and height: 180px. As the container changes width, its displayed ratio changes while the fixed height remains. A circle in the legend becomes an oval and the plotted slopes look different. Inspect computed dimensions rather than only the attributes in the source, because a correct width and height pair can be overridden by later CSS. Temporarily remove the fixed height and compare a known geometric feature with the original.

The aspect-ratio property supplies a preferred ratio within sizing calculations; it does not automatically defeat every explicit width and height constraint. A component that sets both dimensions may still need those constraints revised. Decide which dimension should follow the available reading space and let the dependent dimension preserve the image's shape. If a fixed box is required, separate the box's proportions from the image content's fitting behavior. The box may be square while the contained chart remains rectangular with unused space around it.

Also verify that the source file has not already been distorted during an earlier export. A browser can faithfully preserve an incorrect intrinsic ratio, so changing CSS until the figure resembles a remembered version is not enough. Compare it with the approved original and check axis labels, circles, and any area-based encoding. Do not apply a compensating scale transform that only corrects one preview size. The final test should show consistent geometry at narrow and wide widths, with enough detail to read the chart's units and not merely recognize its general outline.

## Verify the repaired artifact

Check a known shape and a labeled axis against the source. Correct proportions should persist as the container narrows.

## Sources and further reading

- [MDN: aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/aspect-ratio)

## Related guides

- [Understand a stylesheet blocked by an integrity mismatch](https://githtml.com/guides/integrity-hash-blocks-stylesheet)
- [Why malformed table markup moves text outside the table](https://githtml.com/guides/invalid-table-markup-moves-content)
- [Find images that were never loaded before saving](https://githtml.com/guides/lazy-images-missing-saved-report)
- [Why module scripts behave differently in file-based HTML](https://githtml.com/guides/module-script-local-html-fails)

Editorial approach: https://githtml.com/guides/about
