CSS Visual Formatting

width

This property specifies the content width of the elements.

 

HTML snippet

<div>

Hello world! Welcome to this tutorial page!

</div>

CSS snippet

div{

background-color: #e1e1e1;  /*light gray color*/

width : 200px;

}

Output:

The width of the <div> element is reduced to 200px;

*Try removing the width property and test the difference.

 

height

This property specifies the content height of the elements.

 

HTML snippet

<div>

Hello world! Welcome to this tutorial page!

</div>

CSS snippet

div{

background-color: #e1e1e1;  /*light gray color*/

width : 200px;

height : 200px;

}

Output:

The height of the <div> element is changed to 200px;

*Try removing the width property and test the difference.

Posted on July 12, 2014 in CSS

Share the Story

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Top