You are here: Reference > CSS > properties > width

width property

Browser support:
Specifies the width of the visible area for an element.
This property has effect only on block-level elements or on elements with absolute or fixed position. The overflowing content can be manipulated by the overflow property.
The width property contains only the width of the visible contents with the vertical scrollbar, but without the padding, border and the margin.
JavaScript page for this property: width. You can find other example(s) there.

Possible values:

 One of the following values: 
auto
Default. The width of the object is determined by the values of other properties.
inherit
Takes the value of this property from the computed style of the parent element.
width in non-negative length
The width of the element in length units. For the supported length units, see the length page.
width in non-negative percentage
The width of the element is the specified percentage of the width of parent element.
Default: auto.

Example HTML code 1:

This example illustrates the use of the width property:
<head>
    <style>
        .example {
            background-color: #E9E9E9;
            width: 300px;
            height: 200px;
        }
    </style>
</head>
<body>
    <div class="example"></div>
</body>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content