'css max-height or max-width to restrict image size

Why should you not use max-height to restrict the size of an image?

Both max-width and max-height can be used to restrict the size of en element.

This WC article suggests using max-width to fit the image in its container. https://www.w3.org/WAI/WCAG21/Techniques/css/C37

Is there any reason not to use max-height to restrict size of an image should you have a web applicatin with vertical content flow?

https://developer.mozilla.org/en-US/docs/Web/CSS/max-height

https://developer.mozilla.org/en-US/docs/Web/CSS/max-width

css


Solution 1:[1]

max-height vs. max-width : the case for setting max-width

  1. Setting both max-height and max-width can change the aspect ratio of the image, which is often not desired
  2. Setting max-width can be used to ensure that the image "fit" horizontally. In most cases this is preferable, as people are used to scrolling web pages vertically, but not so much horizontally.

With that being said, it is up to you to determine which to use based on your requirements

Solution 2:[2]

Yes. Some pages have content placed horizontally :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ControlAltDel
Solution 2 apocalypse