The Width Property


The width property sets the width of the element. It is seldom used with block-level elements. In fact, its use with such elements may lead to some complications. This property is most useful with replaced elements (such as IMG) and floating text elements.

Name:

width

Value:

<length> | <percentage> | auto

Initial:

auto

Applies to:

block-level and replaced elements

Inherited:

no

Percentages:

refer to parent element's width


This property has three types of values:

  • Length An absolute or relative value.

  • Percentage A percentage of the width of the element in which this element is contained; for example, 80% means the element is 20% narrower than the containing block.

  • auto This is the default.

By default, width has the value auto. Usually, you won't set the width of a block-level element explicitly; you set only the margins, padding, and border. Exceptions are possibly the HTML element and tables or table columns. The actual width of the element is what is left after you subtract the margin, padding, and border from the available width, also called the inherited width. We detail how to work with the width property in the section, "The whole story on width computation."



Cascading Style Sheets(c) Designing for the Web
Cascading Style Sheets: Designing for the Web (3rd Edition)
ISBN: 0321193121
EAN: 2147483647
Year: 2003
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net