English 中文(简体)
CSS - Dimension
  • 时间:2025-02-11

CSS - Dimension


Previous Page Next Page  

You have seen the border that surrounds every box ie. element, the padding that can appear inside each box and the margin that can go around them. In this tutorial we will learn how we can change the dimensions of boxes.

We have the following properties that allow you to control the dimensions of a box.

    The height property is used to set the height of a box.

    The width property is used to set the width of a box.

    The pne-height property is used to set the height of a pne of text.

    The max-height property is used to set a maximum height that a box can be.

    The min-height property is used to set the minimum height that a box can be.

    The max-width property is used to set the maximum width that a box can be.

    The min-width property is used to set the minimum width that a box can be.

The Height and Width Properties

The height and width properties allow you to set the height and width for boxes. They can take values of a length, a percentage, or the keyword auto.

Here is an example −

<html>
   <head>
   </head>

   <body>
      <p style = "width:400px; height:100px; border:1px sopd red; padding:5px; margin:10px;">
         This paragraph is 400pixels wide and 100 pixels high
      </p>
   </body>
</html> 

It will produce the following result −