Type Here to Get Search Results !

Lesson 12: Height and width

Up until now, we have not cared much about the dimensions of the elements we have worked with. In this lesson, we will take a look at how you easily can define the height and width of an element.

Setting the width [width]

With the width-property, you can define a certain width of an element.
The simple example below provides us with a box wherein text can be typed:


show example 

Setting the height [height]

In the example above notice how the height of the box is set by the content of the box. You can affect the height of an element with the property height. As an example let us try to make the box in the example 500px high:


show example 

Summary

Lesson 9, 10, 11 and 12 have given you an introduction to the box model in CSS. As you can probably see, the box model gives you many new options. You might have been using tables in HTML to create your layouts until now, but with CSS and the box model you should now be able to achieve elegant layouts more precisely and in accordance with the recommendations of W3C.

Post a Comment

0 Comments