CSS/Properties/width

From W3C Wiki
< CSS‎ | Properties
Revision as of 18:07, 16 June 2011 by Hiroki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

width

The width property specifies the content width of boxes.

Description

Values <length> | <percentage> | auto | inherit
Initial value auto
Applies to All elements but non-replaced inline elements, table rows, and row groups
Inherited No


Values

  • <length>
    Specifies the width of the content area using a length unit.


  • <percentage>
    Specifies a percentage width. The percentage is calculated with respect to the width of the generated box's containing block.


  • auto
    The width depends on the values of other properties.


  • inherit
    Takes the same specified value as the property for the element's parent.


Example

Example A

[style.css]

 p {
   width: 400px;
   height: 200px;
   background-color: #999;
 }

[index.html]

<body>
  <p>This is a paragraph.</p>
</body>


Csslist2 width.png

CSS Reference

The CSS specification defines the width property in 10.2 Content width.