First Promotions

CSS Box Model


When the term 'CSS Box Model' is used, it usually refers to design and layout within CSS. The box model shows how a html element (box) and its properties relate to each other. The box model basically tells the browser that a box is defined with certain properties (height, width) and the browser should display this box with its properties in a way that the page can manage e.g. height 50 px means 50 px tall. Besides height and width, there are many other different properties which can be used on certain objects, These properties can include:

CSS Example

<Style type="text\css">

body

{

margin-top: 25px;

margin-left: 0;

margin-right: 0;

padding: 2px;

background-color: #ff0000;

}

</style>

Description

In this example, the body tag is being set properties. The margin will indent the page by 25 px from the top of the window and other margins will be ignored because they are set to 0 px. Padding will be wrapped around the body section by 2px and the background of the body section will be coloured red.


Valid XHTML 1.0 Strict