Set height auto in HTML and CSS

Description

The following code shows how to set height auto.

Example


<!--from   w  ww. j a  v a 2 s. c o  m-->






<html>
<head>
<title>auto width and height</title>
<style rel='stylesheet' type='text/css'>
img#x-aspect-1 {
border: 1px solid black;
margin: 5px;

width: 200px;
height: auto;
}
</style>
</head>
<body>
<div>
<img src='http://www.java2s.com/style/download.png' id='x-aspect-1' />
</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Set height auto in HTML and CSS