Is there a need for zero-out DIV's margin and padding?
I wonder if on any browser div
element comes with a preset margin/padding value other than zero. As far as I know, div
and span
come with zero padding and margin values by standard to make them suitable c开发者_开发百科anvas for style decoration.
Even better, is there a definite standard for default styles for all elements that is cross-browser which we can make assumptions upon? For instance FORM comes with top/bottom margin
s, OL/UL come with padding-left
's.
I occasionally see a
* {
margin: 0;
padding: 0;
}
and this just looks like a dirty hack without knowing the reasons or consequences. Anyone has any better approach to this?
Different browsers have different defaults -- this is why using CSS resets like these
- http://meyerweb.com/eric/tools/css/reset/
- http://developer.yahoo.com/yui/reset/
are popular in order to insure that browsers are treating all the elements equally. It gives you a baseline and then expects you to define all the relevant styling.
精彩评论