Glubase - share your knowledge


All / Computers / Programming / CSS





  • View Command

CSS Reference

CSS width definition

Syntax

width: <length> | auto

Description

The width property specifies the width of an element.

Values Description
auto Default. The browser calculates the width of the element.
percentage Defines the width in percentage of the parent element's width.
length<unit> Defines the exact width of the element. For example: 5px. The unit can be any of px (pixels), mm (millimeters), cm(centimeters), in (inches), pt (points), pc (picas), em (the element's font height) or ex (the element's x-height).

 

Example

[Try this example yourself]
<style type="text/css">
img.auto
{
width: auto
}

img.big 
{
width: 250px
}

img.small 
{
width: 60px
}
</style>

<img class="auto" src="http://www.glubase.com/images/glubase2.gif" />
<br />
<img class="big" src="http://www.glubase.com/images/glubase2.gif" />
<br />
<img class="small" src="http://www.glubase.com/images/glubase2.gif" />

Output



  • Comments

No comments added.