Property Description
The width property sets the width of an element, but does not include the padding, borders, or margins.
This property has the following syntax:
width: auto|length|%|initial|inherit;
Property Values
Value | Description |
---|---|
auto | (default) The browser calculates the width |
length | Defines the width in px, cm, etc. |
% | Defines the width in percent of the containing block |
initial | Specifies that the value of the property should be set to the default value |
inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
This example sets the height and width for a paragraph.
p.note {
height: 100px;
width: 100px;
}
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
1.0 | 1.0 | 4.0 | 1.0 | 3.5 |
Miscellaneous Information
Inherited: | No |
---|---|
Defined In: | CSS1 |
Default Value: | auto |
Property Description
The min-width property sets the minimum width of an element. This does not include padding, borders, or margins.
This property has the following syntax:
min-width: length|%|initial|inherit;
Property Values
Value | Description |
---|---|
length | (default is 0) Defines the minimum width in px, cm, etc. |
% | Defines the minimum width in percent of the containing block |
initial | Specifies that the value of the property should be set to the default value |
inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
This example sets the minimum width for a paragraph.
p {
min-width:100px;
background-color: yellow;
}
<p>The minimum width of this paragraph is set to 100px.</p>
This produces the following result:
The minimum width of this paragraph is set to 100px.
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
1.0 | 3.0 | 7.0 | 2.0.2 | 4.0 |
Miscellaneous Information
Inherited: | No |
---|---|
Defined In: | CSS2 |
Default Value: | 0 |
Property Description
The max-width property sets the maximum width of an element. This does not include padding, borders, or margins.
This property has the following syntax:
max-width: none|length|%|initial|inherit;
Property Values
Value | Description |
---|---|
none | (default) No maximum width |
length | Defines the maximum width in px, cm, etc. |
% | Defines the maximum width in percent of the containing block. |
initial | Specifies that the value of the property should be set to the default value |
inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
This example sets the maximum width for a paragraph.
p {
max-width:100px;
background-color: yellow;
}
<p>The maximum width of this paragraph is set to 100px.</p>
This produces the following result:
The maximum width of this paragraph is set to 100px.
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
1.0 | 1.0 | 7.0 | 2.0.2 | 7.0 |
Miscellaneous Information
Inherited: | No |
---|---|
Defined In: | CSS2 |
Default Value: | none |