HTML Element Style How to - Prevent an empty img element from shrinkage by setting width and height








Question

We would like to know how to prevent an empty img element from shrinkage by setting width and height.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img.uploadPreview {<!--from   w  ww.  j a v a 2  s .c  o  m-->
  width: 90px;
  height: 120px;
  border-style: groove;
  display: block;
}
</style>
</head>
<body>
  <img width="90" height="120" class="uploadPreview"  />
</body>
</html>

The code above is rendered as follows: