Javatpoint Logo
Javatpoint Logo

CSS Width

The CSS width property is used to set the width of the content area of an element.

It does not include padding borders or margins. It sets width of the area inside the padding, border, and margin of the element.

CSS width values

Value Description
auto It is a default value. it is used to calculate the width.
length It is used to define the width in px, cm etc.
% It defines the width of the containing block in %.
initial It is used to set the property to its default value.
inherit It is used to inherit the property from its parent element.

CSS Width Example: width in px

Test it Now


The height and width of this paragraph is 150px.

This is a paragraph.

CSS Width Example: width in %

The percent width is a measurement unit for the containing block. It is great for images.

Test it Now


Note: You can also use the "min-width" and "max-width" property to control the size of image.

Next TopicCSS Word Wrap

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA