HTML Element Style How to - Scale Image size dependent on browser size








Question

We would like to know how to scale Image size dependent on browser size.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!--  w  w  w  . j  a v a  2  s .  co  m-->
  width: 100%;
  height: auto;
}
</style>
</head>
<body>
  <img src="http://www.java2s.com/style/download.png">
</body>
</html>

The code above is rendered as follows: