Close
Close

Your Name Here

  • Home
  • KarmaCMS
  • Wizard Manual
  • Tips
  • Be A Reseller
  • FAQ
  • Contact/Support
  • Questionnaire
  • Links
  • Free Training Courses

Tips

This is another variation on the "misc" module and some useful tips when using the Karma Design Wizard.
More Tips:  
  • Creating Repeating Backgrounds
  • Saving Graphics For The Web
  • Layout Styles
  • Search Engine Optimization
  • Margin Vs. Padding
  • Saving Transparent Images in Photoshop
The difference between margin and padding can be baffling to folks just starting out with web design. After all, if there is no background color or background image involved they appear to do the same thing. If you tried to figure out the difference when IE 5 or IE 5.5 was the major browser you would be even more confused since the browser itself got it wrong. Luckily, IE6 improved it's "box model" and today all major browsers get it right.
The Basic Concept
It's actually a simple concept and once you understand you'll never forget. Think of your container such as "content" or "header" as a house. Margin is the space between your house and the next building. Padding is the space between your wall and your furniture. If you were to paint your "house" it would only apply to what's inside of it instead of the alley way between your house and your neighbor's.

Margin effects the outside of the container to which it is applied. The greater the margin, the greater the distance between it's container and the next. Padding effects the inside of its container, increasing the distance between the edge and the content within. Once background colors or images are applied the difference becomes more apparent.
When It Gets Tricky
You might be thinking "OK, it doesn't really matter as long as I don't use a background color or image." Well, that's true as long as you aren't giving your container a width. If you give a container a width you have to keep in mind that width includes the padding dimensions. It would be nice if that weren't the case, but alas it is true. I'm sure someone somewhere has a good reason for creating it this way...

Suppose you have a fixed width container within a container such as individual teasers within the teaser group and neither have a background color or image. You would like to put some space between the teaser group wall and the the teaser it holds. Does it matter if you use padding or margin? Yes.
Padding + Width = Actual Width
If you choose to use padding you will place it on the outside container since it's the content inside of it you want to move over. Placing padding on this fixed width container will cause its actual width to expand in the amount of both padding-right and padding-left combined. For example, if your declared width is 200px, and your padding-left and padding-right are each 20px, the actual width will now be 240px.

   Declared Width (200px)
+ Padding-left (20px)
+ Padding-right (20px)
-----------------------
= Actual Width (240px)


If this container needs to fit within a 200px wide space you'll need to adjust the declared width to 160px to compensate for the padding.
Margin
If you choose to use margin it should be placed on the inside container, in this example the individual teaser. Because you are only telling the inside container to change and not the outside one, the width isn't effected and no further adjustments need to be made.
Launch The Karma Wizard
Module Testing List
Blog
Contact
Events
FAQ
Files
Flash Intro
Forms
Forum
Guestbook
Links
Misc
Music
Pedigree
Photos
Polls
Press/Quotes
Profiles
Song List
Splash Page
Store
Users
Video
read descriptions
Polls Teaser
Are The Training Courses Helpful?
Yes, absolutely!
Sort of...
Not really.
I don't know - I haven't tried them.
What training courses?
View Results
New Layouts - Cracking the Code
Aug 29, 2007
Hi All. I've put up a plethora of new layouts. There are so many to sift through it will become overwhelming. We plan to create a search, but until then ... read on
Show All
Press Teaser
More Quotes
HostKarma
more
Join the List
If you'd like to be notified of events, enter your email address below.
The Karma Wizard is currently in beta testing, meaning that it is pretty stable, but there still may be a few bugs or other issues to shake out. If you encounter any problems, please send an email to bugs@karmawizard.com and we'll try to address them as quickly as possible.
Powered by KarmaCMS