Computer >> Computer tutorials >  >> Programming >> CSS

Set the width of a box with CSS


The width property is used to set the width of a box. They can take values of a length, a percentage, or the keyword auto. 

Example

You can try to run the following code to set the width −

<html>
   <head>
   </head>
   <body>
      <p style = "width:200px; height:50px; border:2px solid green; padding:15px; margin:20px;">
         This paragraph is 200pixels wide and 50 pixels high
      </p>
   </body>
</html>