CSS can be tricky. There are lots of things that can go wrong, or at least not as you expect, and trying to determine what the problem is can be almost as hard as writing the CSS in the first place. The key to finding and fixing your CSS problems is three-fold:
- finding the problem
- isolating the cause
- fixing it
Find and Fix CSS Problems by Thinking Small
While your goal is, of course, to fix the problem, but in order to do that, you need to find the problem. And the best way to do that is to think small. What is the smallest amount of HTML and CSS code that you can create and still generate the problem? The advantage to this is that often you'll see what the cause is while you're looking for the problem.
And if you can't find it, the smaller a chunk of code you have the more likely you'll be able to find help in Web design forums and from your friends and co-workers. No one wants to look at 3000 lines of someone else's (or even their own) code. But most people won't hesitate to look at 10-20 lines.
First Thing: Simplify the Page
Step 2: Move It to Your Hard Drive Away from the Server Files
An easy way to find external files is to use your editor to search for "http:". If you don't use full URLs for your file references, you'll need to search the document manually for the locations of external files. If you can turn off your internet access, for example, by turning off your wireless card, this can help you find external files too.
Step 3: What Browsers Are Affected?
Most CSS problems are not equal because the browsers that display them aren't equal. So before you start isolating the cause of your problem, you need to make sure you know where it happens. Open the local file in your favorite browser and then as many other browsers as you can. It's best if you can do your testing on a system with a virtual machine, so that you can test in both Windows and Macintosh browsers.
You need to know which browsers the problem occurs in so that you can test in those browsers to find a fix. But don't forget to test in the working browsers as well. A fix for one browser might result in breakage in another.
Step 4: Start Your Simplifying
Once you have your page isolated, start simplifying what you have on the page. Remove both HTML and CSS, periodically testing to make sure the problem is still there. Cut away as much of the HTML and CSS as you can without removing the problem completely. This is isolating the cause.
For example, if the problem is in your navigation, then you can get rid of all the HTML that isn't building the navigation: internal div tags, headers and footers, etc. Once you have the minimum HTML required to keep the problem happening, then start paring away the CSS. Be sure to test every few minutes. Sometimes the stupidest things can cause the problem, and you won't know what made it go away until you try. Once you've removed a line of CSS or HTML and the problem disappears, make a note of that line and put it back in your document. If you can tell how to fix it from that line, then you're done. Otherwise, keep removing lines and testing what happens.
You can remove one line of CSS or HTML then test. If the problem is still there, save the file and do it again. If the problem is not there, either fix the problem or put the line back and make a comment and keep going. It's slow going, but it works.