HTML Element Style How to - Keep aspect ration based on height








Question

We would like to know how to keep aspect ration based on height.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!--from w w w.jav  a2 s.co  m-->
  max-width: 550px;
  max-height: 440px;
}
</style>
</head>
<body>
  <img src="http://www.java2s.com/style/download.png">
</body>
</html>

The code above is rendered as follows: