Set width for an image : img width « Tags « HTML / CSS






Set width for an image

      
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
        <title></title>
<style type="text/css">
img {
  width: 300px;
  border: 6px double #666;
  background: #fff;
  padding: 4px;
  display:block;
}

a:link {
  display:block;
}

a:hover img {
  border-style: solid;
  background: #999;
}

</style>

    </head>
    <body>

<a href="http://www.www.java2s.com"><img src="http://www.java2s.com/style/logo.png" alt="Face" /></a>
    </body>
</html>

   
    
    
    
    
  








Related examples in the same category

1.Image with fixed width and height
2.Shrinkwrapped image by setting both width and height to auto
3.Stretched Image by setting both width and height to 100%
4.Image auto width and height
5.'units' defines the units by which the height and width attributes are measured