Proper Use of Padding and Margins in CSS
Being a web designer, most of our problems when it comes to browser issue is Internet Explorer. 30% users are still using Internet Explorer 6.0 so we still need to test our web design in IE 6.0
But how we can create a CSS code that will solve the IE browser Issue? Our design are perfect in most browser but when it comes to IE, it sucks! And we need to debug it. I don’t used a hack in IE for my design so my layout is proper in IE browser. I just want to challenge IE for this issue especially in padding.
There is a proper way of using between padding and margins, however sometimes if you used margins you got a browser issue in IE. So I will advised you to use padding for alignment so IE can’t suck you.
How to center align a 800px width in IE Browser
Using the below code, your web alignment of 800px will be align properly in IE, Firefox,Safari, and Opera.Using an (auto) command, your layout will display properly in all browsers especially IE.
Your CSS
width: 800px;
margins: 0px auto 0px auto;
border:solid 1px #000;
}
.content{
width:600px;
margins: 0px auto 0px auto;
border:solid 1px #000;
}
Your HTML
<title>Your Title Here</title>
<head></head>
<body><div class=”center_align”><div class=”content”>Sample content</div></div>
</body>
</html>
How to used padding in IE browser Issue
This sample code will align your design properly if you are using a (padding) command. Proper using of padding can avoid any browser issue in most browser especially in IE.
Your Original CSS
width:300px;
padding-left:10px;
padding-right:15px;
}
Your Final CSS
You will noticed that the above (Original CSS) is different from the (Final CSS). I will explain it to you why is that happen.
We have width of 300px and we used a padding-left:10px and padding-right:15px. But since we are using padding left and right, the 300px becomes 275px. And ones we add the 275+10+15, the width is still 300px. Try to apply this in your site so you can see if it is working.
Why? Because we used the padding left and right. Using padding is increasing the with, that is why we decrease the orignal with of 300px to 275px.
This is the (Secret of CSS) so your layout is not sucks in Internet Explorer browser and compatible in all browser.
I hope you understand what I meant. If you have questions, I am happy to assist you.
width:275px;
padding-left:10px;
padding-right:15px;
}
Your HTML
<title> Your Title Here </title>
<head></head>
<body><div class=”leftside”></div>
</body>
</html>
Possibly Related Posts:
- September 6, 2010 Hosting Expiration
- Avoid Adbrite and Infolinks get Together
- Increase Your Earnings with Related Tags of Infolinks Advertisement
- Pay Per Click Advertising Websites
- Learning SEO From the Experts Guides
If you enjoyed this post, make sure you subscribe to my RSS feed!
10 Responses
to “Proper Use of Padding and Margins in CSS”
9 Trackback(s)
- Aug 9, 2009: Proper Use of Padding and Margins in CSS | aasighee.com
- Aug 9, 2009: Proper Use of Padding and Margins in CSS
- Aug 9, 2009: Proper Use Of Padding And Margin In CSS | Design Newz
- Aug 9, 2009: Proper Use of Padding and Margins in CSS - Programming Blog
- Aug 10, 2009: CSS Brigit | Proper Use of Padding and Margins in CSS
- Aug 13, 2009: tripwire magazine | tripwire magazine
- Aug 14, 2009: Proper Golf Attire Is Good For The Golf Course Establishment | Supreme Golf Shop
- Aug 19, 2009: Proper Use of Padding and Margins in CSS | Choose Daily
- Feb 23, 2010: pligg.com




Hello guys! My name is R3ALISTIC WEB - a.k.a "R3" . I am fulltime / freelance web designer and blogger wanna be from the Philippines. R3ALISTIC is a blog site all about tutorials, design, ideas, and daily web trends. 





































Hi there sir, good day!,
Thanks for sharing this, i hope this will fix my problem in the very annoying browser (IE 6). lol.