Lunarpages Internet Solutions Blog
  • Home
  • About Us
  • LunarForums
  • Free Web Tools
  • LunarMods
0

Padding Versus Margins in CSS Design

7 April, 2010 - Design, Mitch Keeler

CSS Help Tutorial

Do you know the different between padding and margins in CSS web site design?  That was the very interesting question posed to me via e-mail by one of the great Lunarpages web hosting customers, yesterday.

I have trouble telling the difference between what padding is in CSS code and what the margin is, when I set both around a div or class.  Could you explain?  Thanks!

The quickest rule of thumb I can share to tell the margin and the padding apart is very simple.

The margin is always the space outside of the element you are working with, and padding is always inside the element you are working with.

What is Padding?

The padding in CSS terms is there to clear a space around the inside of an element.  Think of it as having a house filled with chairs.  You then move all the chairs to the middle of the house, to make more room to move around the outside of the general “chair space”.  This empty space would be your proverbial padding.

Example Padding Use:

padding-top:10px;
padding-bottom:15px;
padding-right:10px;
padding-left:15px;

What is Margin?

The margin in CSS terms is defined as the space outside the element.  Looking at the house metaphor again, you could think of the margin as the empty space all the way around your house. 

Example Margin Use:

margin-top:20px;
margin-bottom:20px;
margin-right:20px;
margin-left:20px;

So, I hope this helps our confused reader and Lunarpages web hosting customer on the differences between the two and helps all of you too.  If you would like to see more CSS tutorials, tips and more be sure to leave me a comment!

Archives

Categories

View more:

  • About the Lunarpages blog
  • Best Blog Hosting Guide
  • BOTW.org 40% Discount
  • Contact Lunarpages
  • Free Online Tools
  • Free Webmaster Downloads
  • Free Wordpress Themes

Best Web Hosting

Lunarpages.com Web Hosting

Recent Posts

  • Enjoy Backup and File Sync with Sync TOGO
  • JugnooMe: Making Your Business Social Is Our Business
  • An Explanation of HTML5 for Beginners
  • How to Ensure Your Website is Optimized for Top Speed
  • Tips Every Webmaster Should Keep in Mind to Improve On-Page SEO

Recent Comments

  • jocuri kizi on Affiliate Marketing – Part 1 – Why the heck are you not doing this?
  • Kurt on Choosing the Best Ecommerce Shopping Cart
  • Vmelissap123 on Are You Smarter than a 5th Grader?
  • Brennan Scurlock | Review of top 10 web hosting providers. on Site of the Month – Team Brennan
  • iyinet on 10 Best Bookmark and Share WordPress Plugins

@Lunarpages Feed

Who We Are

  • Web Hosting Services
  • About us
  • Partners
  • Affiliate Program
  • Specials
  • 24/7/365 Support Desk
  • Community Forum
  • WIKI

Our Products

  • Colocation Services
  • Fully Managed Services
  • Dedicated Hosting
  • VPS Hosting
  • Microsoft Exchange
  • Open-Xchange
  • Fax To Email
  • Linux Hosting
  • Windows Hosting
  • Reseller Hosting
  • Quicksite Website Builder
  • SEO & SEM Services
  • Payment Processing
  • SecureLive Website Security
  • Tremendesk - Help Desk Solution

Connect With Us

Stay in touch with us!

Sign up for our monthly newsletter to receive updates, news, and current promotions!

Twitter
Facebook Google+ RSS Feed


© 2000 - 2011 Add2Net, Inc. "Lunarpages", "Add2Net" and the "Lunar Symbol" are the trademarks or the Registered trademarks of Add2Net, Inc.
All rights reserved. Unauthorized use is prohibited.