Forum Moderators: not2easy
I have found that by using the this style at the begining of my style sheet my page resolves well aligned in many different browsers but if I leave it out I have to compensate in the style for div spacing problems.
* {
margin: 0;
padding: 0;
}
Why does this work and where is if documented?
If I put the same style in the html or body style it does not work the same way.
Thanks,
Nouturns
* { /* ... */ }
That will match every element in your document, while if you apply the style like this:
html, body { /* ... */ }
that will match ONLY the html and body elements (thus, child elements of body might still have different default padding/margin).
The * is the "universal selector":
[w3.org...]
I was starting my style sheets with something like this...
h1, h2, h3, p, ul {
padding: 0;
margin: 0;
}
Now using the * selector to set the page to zero is just easier.
Every browser I have tested this in it works.
Nouturns
Each has its own pro's and con's. Becoming aware of the cons for each would give you a better understanding of best choice for you.
I personally use the * reset because I know everything is reset to 0 so for me bug fixing becomes easier. I like the idea of the yahoo reset but I might miss something that I otherwise wouldn't have.
Each to their own but I would strongly urge you to research all options and then form an opinion.