CSS Margin

CSS Margin can be used to manipulate the space around an HTML element.

The below div have absolutely no margin on it.

No margin

If we add 10 pixels margin:

10px margin

As you can see, the CSS: .my_div { margin:10px; } adds 10 pixels of margin on ALL sides of the element. This includes the top AND bottom, left AND right, so be careful when positioning elements and calculating widths. A 10px margin on an element makes it 20 pixels wider, and 20 pixels higher.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MSN Reporter
  • MySpace
  • PDF
  • Ping.fm
  • Posterous
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
This entry was posted on Saturday, January 16th, 2010 at 10:43 pm and is filed under CSS Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

1 Comment

  1. CSS Padding - CSS Tutorials and CSS Articles says:

    [...] Padding January 16, 2010 – Posted by CSS Master CSS Padding is similar to CSS Margin and part of the CSS Box [...]

    ... on July January 16th, 2010

Post a Comment