The height and width properties in CSS are used to set the height and width of an element, respectively.

Here is an example of how to use the height and width properties:

p {
height: 100px;
width: 200px;
}

In this example, the height property sets the height of the <p> element to 100 pixels, and the width property sets the width of the element to 200 pixels.

The height and width properties can accept a value in pixels, as a percentage of the available space, or as one of the following keywords:

  • auto: The element's height or width is automatically set to the size of the content.
  • min-content: The element's height or width is set to the minimum size required to fit the content.
  • max-content: The element's height or width is set to the maximum size required to fit the content.
  • fit-content: The element's height or width is set to a size that fits the content, but may be larger than min-content or smaller than max-content.

Here is an example of how to use these keywords:

p {
height: min-content;
width: max-content;
}


In this example, the height property sets the height of the <p> element to the minimum size required to fit the content, and the width property sets the width of the element to the maximum size required to fit the content.

It is generally a good practice to use the height.