CSS Tips


- Group Your Margin Attributes

This code works in IE 3.02 and 4.0.

When using Style Sheets, you can set margins for the entire document in the BODY section. The margin-left, margin-right, and margin-top attributes set the side margins and top margin. You can specify the margins in points, inches, centimeters, or pixels in positive and negative numbers. For example:

	BODY {margin-left: -10px;
	      margin-right: -10px;
	      margin-top: 20px}
However, instead of setting the margin attributes separately, you can combine them into one attribute called margin. Instead of the code above, you can simply use:
	P {margin: 20px -10px-10px}
The implied order for margin is top, right, and left. If you specify a single value, it will be applied to all three margins.


Back to the Building Web Pages