| When people hear the words CSS, they often freak | | | | off from browser to browser. |
| out especially if they come from a Table based | | | | Using a second set of divs for padding |
| background. But please, don't be scared. It's a nice | | | | Another method I use to deal with margin/padding |
| world to be in once you get the hang of it. With the | | | | issues across browsers is when there are 2 |
| tips below, I hope to give you some baby steps in | | | | containers floated side by side, and you give padding |
| creating cross-browser friendly CSS tips so your | | | | to them. Internet Explorer will treat this differently |
| websites look the same in any web browser. | | | | then say Firefox. The key is to embed an extra pair |
| Star-Selector Reset | | | | of DIV's inside the main containers, and apply the |
| To start off, we want to begin our CSS document | | | | padding to those internal divs. Case in point: In the |
| with what is known as the star selector (*). Your | | | | code sample below, 200px width will actually become |
| code will be this simple: | | | | 220px because of the 10px side padding. |
| * {margin: 0px; padding: 0px;} | | | | Instead, you want the width to stay 200px, and the |
| What that does is tell the web browser to interpret | | | | padding to apply inside. The solution is one extra DIV |
| ALL HTML elements (h1, p, UL, LI, etc...) to have NO | | | | pair with the 10px padding applied like such: |
| padding and NO margins. It's literally a global reset. | | | | I posted sample code on the Pastie Code website: |
| Now, in your css when you give an element a | | | | pastebin.com/pgi2c4yb |
| particular MARGIN or PADDING, every browser that | | | | So between the * selector reset and applying your |
| reads it will adhere to those rules. By default, every | | | | box padding to an internal set of div's, your |
| browser has its own DEFAULT method of handling | | | | cross-browser attempts will be much more |
| the margins and paddings, which throw your layouts | | | | successful. |