close[x]


CSS

CSS-Home CSS-Environment CSS-Basic syntax CSS-Selector CSS-How To Add CSS CSS-Comment CSS-Color CSS-Background CSS-Font CSS-Text CSS-Boarder CSS-Margin CSS-Padding CSS-Height/Width CSS-Link CSS-Table CSS-Visibility CSS-Scrollable CSS-Float/Clear CSS-Line CSS-Align CSS-Dimension CSS-Event CSS-Pusedo class CSS-Position CSS-Transparency CSS-Dropdown CSS-Form CSS-List/Counter CSS-Website layout CSS-Text effect CSS-Image effect CSS-Button effect CSS-page number CSS-Box CSS-@media CSS-Multi device CSS-Multi device 1 CSS-Multi device 2



learncodehere.com




CSS - Height and Width

The height and width property allows you to specify the height and width an element.

It sets the height/width of the area inside the padding, border, and margin of the element..

All the height and width properties can have the following values:

  • length - specifies a height and width in px, pt, cm, etc.
  • % - specifies a height and width in % of the containing block.
  • auto - This is default and the browser calculates the height and width.
  • initial - Sets the height/width to its default value.
  • inherit - The height/width will be inherited from its parent value

  • Example : CSS - Height and Width

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    p{
    height: 100px;
    width: 500px;
    background-color: blue;
    }
    </style>
    </head>
    <body>
    <p>Code Always.<p>
    </body>
    </html>

    When the above code is compiled , it produces the following result.

    Result

    Code Always.


    You can set CSS height/width properties inline, internal and external way of using CSS in your HTML page.