HTML Element Style How to - Grow Image with browser width








Question

We would like to know how to grow Image with browser width.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!-- w  ww.  j a  v  a  2s .  c o  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: