The answer is to make your HTML and CSS standards compliant and properly structured. Unfortunately, this is hard for a lot of reasons, not the least of which is that most of the web browsers don’t complain about bad HTML or offer any tools to help you find problems.
Which is why I wrote The Central Scrutinizer. This program will give you a summary of different kinds of errors on your web page from most severe to least. Clicking on an error group will take you to the errors and clicking on an error will show you where it is in your HTML or CSS.
If you find problems with the results, please use the comment form on the Scrutinizer or leave me a comment here. I hope you find it useful.