HTML PRIMER

by Jim Gordley
2008-2016

Default attributes

All browsers have default display attributes. The problem is that not all browser programs use the same default attributes. One browser may have a two pixel margin the next might have a four pixel margin. Other default attributes include text size, font face, background color and so on. Using CSS we can change default attributes to virtually any style we want our pages to have. In this topic we are going to concentrate on the margin attribute, that space between the browser window and page content.

Controlling page margins

Controlling page margins is best done using a style sheet (CSS) Earlier you learned that there are three types of style sheets.
External Style Sheets
Enternal Style Sheets
In line Style Sheets
To change a default margin for the entire <body> element, use the CSS property margin to the margin size you want.

EXAMPLE

body { margin:25px; } Changes the left and right margins to a width of 25 pixels.
body { margin:0px; } Changes the left and right margins to a width of 0 pixels.
body { margin-left:0px; } Changes the left margin to a width of 0 pixels.
body { margin-right:0px; } Changes the right margin to a width of 0 pixels.

Setting the margins with a style sheet ensures that all browser programs display the page with a consistant margin setting.