Quote:
Originally Posted by Arios
Hi guys,
Just by curiosity: in CSS is it better to use, for example:
Code:
* {
margin: 0;
text-indent: 0;
padding: 0;
}
or put it in the the <body>:
Code:
body {
margin: 0;
text-indent: 0;
padding: 0;
}
I mean, is it more in the semantic line or relevant/effective to use one instead of the other?
|
They are not the same. With
Code:
body {
margin: 0;
text-indent: 0;
padding: 0;
}
only the "body box" will have those properties but with
Code:
* {
margin: 0;
text-indent: 0;
padding: 0;
}
all selectors (p, div, blockquote, h1, h2, etc, etc.) will have margin:0, padding:0 and text indent:0. With the first option, for example if you don't define styles for the h1 tag, <h1> will have default values (that is, will have margins different from 0) but with the second option, <h1> wil have null margins, padding and indent. In short: with the second option, you'll set as default margin:0; padding:0 and text-indent:0 for all selectors and you'll be forced to establish values for them (if you want others values for those properties).
None of those options is wrong, to use one or the other will depend of what you want to do
Regards
Rubén