CSS Margins

CSS Margins
Margins are used to create space around elements, outside of any defined borders.

Margin - Individual Sides
CSS has properties for specifying the margin for each side of an element:
margin-topmargin-rightmargin-bottommargin-left
Example 1馃憞

Example 2馃憞

Margin-Shorthand Property 馃憞
To shorten the code, it is possible to specify all the margin properties in one property.
Diagram 馃憞

Example1馃憞

All CSS Margin Properties 馃憞

The auto Value
You can set the margin property to auto to horizontally center the element within its container.馃憞

It is possible to give margins a negative value 馃憞

Margin Collapse馃憞
馃憠 The top and bottom margins of elements are sometimes collapsed into a single margin that is equal to the largest of the two margins.
馃憠 This does not happen on left and right margins! Only top and bottom margins!
Example馃憞

>
Download our HTML & CSS Visual Treat! ebook Here:
Click here
Comments
Join the discussionNo comments yet. Be the first to comment.




