Saturday, August 8, 2009

Margin

* Proper use of space between elements is crucial to a well designed website therefore having a good understanding of margins and how they interact with one another is vital.
* Many HTML elements have default margins (for example, the p tag has a default margin above and below of 1em), however this margin information is provided by the browser therefore it is not always consistent across browsers.
* Due to this fact we often have to set the element margins to zero.
* We can add a margin to the whole element or just a part of it by using one of the following: margin; margin-top; margin-bottom; margin-left; margin-right.
* If you add a margin to an in-line element, for example the strong tag, the margin will only appear to the right and left.
* However if you add display:block; to the CSS style for the element, then this forces the in-line element to render as a block element and have margins all the way round.
* Don't forget, elements like the body tag also have margins.
* If you are setting the integer value of a margin to zero you do not need to add in the unit of measurement.
* The margin value can also be a percentage.

No comments:

Post a Comment