PROPERTY: width

width : length | percentage | auto
 
Version: Level 1
Inherited: No
 
The width property allows you to set the width of an element of text or an image. For example, you could embed an image into a specified position within a text using the float property. Then use the width and/or height properties to specify an exact size for the image. If you set the width of an element to a specified value and set the height property to auto, the element will be scaled proportionally (i.e., you maintain the aspect ratio).
 
length
 
The length value can be in any of the following seven dimensions. Use the abbreviation.
 
Length Abbrev.
centimeters cm
ems em
inches in
millimeters mm
picas pc
pixels px
points pt

 
percentage
 
The percentage value is based upon the total width being defined as 100%.
 
auto
 
The auto value directs the browser to automatically calculate the width. If both the width and height are set to auto, the dimensions of the text or image element remains unchanged. By declaring auto, you can ensure that any previous declaration will not effect the width of the selected element.
 
Code:
img { width: 150mm; }
img { width: 2.85in; }
img { width: 45pc; }
img { width: 36pt; }
img { width: 140%; }
img { width: auto; }
img {
width:  3.0in
height: auto
}

 
or
 
Code:
<img src="images/guru.gif">
<br>
<img src="images/guru.gif" style="width: 55px; height: auto;">

 
Output:
 


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information