It should also be your very first rule so it doesn’t override specific rules that come after it.
Different browsers have different default paddings/margins for different HTML elements. Properly using the wildcard rule as I outline above should get all your page elements to be flush and then you can apply individual margins/padding as needed.
On a Windows box the colors are rendered the same regardless of the browser - the issue is with what each browser does allow you to style (or not) with form controls - these implementations are kind of spotty compared to vanilla tags.
This is a great overview of what you can expect to see for form controls that are styled (and unstyled) from different browsers on different OS’es.
The order doesn’t matter all that much. A rule with a more specific selector will override a less specific one, even if the more specific one comes first. And the universal selector (*) has the lowest specificity of all.
The cascade only comes into play when two rules have the same specificity.
I am aware - would you not place it first with the knowledge that every rule you place after it will inherently be more specific? Also, out of habit, the “universal selector” being a great equalizer, it goes first for me, then body, then my first div etc. Ideally I break up my CSS to manage layout, type and color but when it is all in the header and/or external but for a small site I just go in order of occurrence in the page for the most part.
You are absolutely right that it doesn’t matter much if at all really - it matters more on bigger sites with more CSS and multiple contributors and the greater chance for clash - I am just cautious as a result of the experience.
I understand the cascade and the use of the universal selector well, but I appreciate you explaining. In major commercial sites I have worked on with many code contributors (even with CVS - or as some would suggest because of it) I have seen some interesting things happen as a result of the cascade - as I am sure you have :).
I was just looking for an answer to this as well and found this forum. This problem only seems to appear with IE. The answer I’ve come up with is to include a “spacer” div between your content divs.
If a DIV or element only appears once on a page it is generally a good idea to give it and ID not a class - classes are best for buttons and the like where there may be more than one on the page.
Also H1, H2 etc. are headers and don’t need to be a seperate DIV - you can just style it by targeting it like so: Content h4 { background-color: red; }
Point being, there is no need to recreate the wheel when you already have suitable, semantic HTML tags at your disposal.
Keeping things simple, here is an example that approximates your setup, while getting the nav and content DIVs flush without another, additional “spacer” div which reminds me of spacer.gif’s - the reason to use CSS it so you don’t need code that has no meaning in its context.
Argh … clickAgent75 I misread your post. John W has the right idea … the right tool for the job etc. Floating your divs will do the trick; it’s just a matter of finding that right tool within the layout style you are using.
In my case, I WANTED a small horizontal space between my divs and the amount of space allocated by default by IE was just too much. By creating a class with minimal font size/line size and attributing it to an html element (in this case another div) I was able to get a custom amount of space that I could reuse wherever required.