Home HTML CSS JavaScript React Gamedatum.com
× Home HTML CSS JavaScript React Gamedatum.com

CSS Height and Width properties


The Height and Width properties in CSS define the size of the selected element on the web page.

The Height and Width properties in action:

                 
                  
    <style>
      .size {
        height: 150px; 
        width: 300px; 
        background-color: tomato;
         }
    </style>

      <div class="size">This is a paragraph of 150px height and 300px width.</div>
 
    
    

The output:

This is a paragraph of 300px height and 300px width.

The Min and Max properties:

The Min and Max properties set the maximum or minimum width and height of the selected element.

                 
                  
    <style>
      .size-me {
        min-height: 300px; 
        min-width: 300px; 
        background-color: tomato;
         }
    </style>

      <div class="size-me">This is a paragraph of 300px height and 300px width.</div>
 
    
    

The output:

This is a paragraph of 300px min-height and 300px min-width.

If the screen is resized the minimum height and width will be 300px.