You need a proper doctype so that the page renders in standards compliant mode.
W3C: Recommended list of DTDs
Keep to the standards as far as possible. That's what the browsers are built to follow, so that is the best common ground that you can find. Also, that is what browsers will follow in the future, so you get the best possible prediction for how the code should look to work with future browser versions.
When building, first test the page in a browser that is not Internet Explorer. If you first build for IE, you will be relying on it's rendering errors, and then you will have great problems to make it look the same in browsers that doesn't have those errors. Firefox is the most common non-IE browsers, and also one of the most neutral when it comes to following the standards.
The Firebug add-on for Firefox lets you see exactly what styles are applied to each element, and you can also tweak the styles in real time, so that is a very handy tool.
Try to make the layout as simple and robust as possible, and keep to the original semantics of html if possible. Search engines look for content in elements that was intended for it, like a header in a h1
tag, and text in a p
tag, so by following the original intention for the markup you make your page more visible on the web.
You may have to add some extra styles to suppress quirks in IE, like specifying a height for elements that should manage to figure out their height by themselves, adding display:inline; to floating elements (which still will be block elements) to fiddle the internal rendering flags of IE, or using overflow:hidden to suppress the urge of IE to make all elements at least one character high. Use padding rather than margin where either works, as IE has problems to collapse margins correctly.
Use conditional tags only as a last resort. By using version specific code you get code that you may have to maintain for every new browser version that is released.