CSS Width
CSS Width
The width property in CSS sets the content width of area of the element. These properties do not provide margin and border features. It is used to set the area’s width within the margin, border, and padding of an element.
Width Values
Value | Description |
auto | It is applied for calculating the width, and it is the default value. |
length | This value is referred to describe the width property cm, px, etc. |
% | It describes a containing block’s width in %. |
initial | This value sets the CSS Width property to the default value. |
inherit | The inherit value inherits this property from one of its parent components. |
Example of Width Property: in px
<!DOCTYPE html> <html> <head> <style> img.normal { width: auto; } img.big { width: 150px; } p.ex { width: 150; height: 150px; } </style> </head> <body> <img class= "normal" src= "Rose.jpg" width= "95" height= "84"><br> <img class= "big" src= "Rose.jpg" width= "95" height= "84"> <p class= "ex"> The width and height of this paragraph is 150px. </p> <p> It is a paragraph. </p> </body> </html>
Output:
