CSS - Height And Width Property


CSS - Height And Width Property 

  • The height and width properties permit us to set the height and width for boxes.  
  • They can take estimations of a length, a rate, or the keyword auto. 

Example: 

p{
width: 300px;   
height: 100px;
border: 1px solid red

Sample Code: 

<! DOCTYPE html> 
<html> 
    <body> 
        <p
style="width:300px; height:100px; border:1px solid red; "
            Welcome To Wikitechy 
        </p> 
    </body> 
</html>

Code Explanation: 


    In CSS, Width property is used to allocate a width for an element. Here we had specified the width of a paragraph tag as 300 pixels. 

    Similarly, height property defines the height of an element where we have mentioned 100px . 

    Border property creates a border around an element. Border values 1px solid red defines the border strength,style and color respectively. 

Output: 


    Here, the text “Welcome to wikitechy” have a height of 100pixels and 300pixels width around the contents from the border. 

    Border around the text “welcome to wikitechy” appears in red color with solid style as displayed in the browser window.