Best practice: How to use (repeat) CSS style attributes correctly?

Posted by ellie on Stack Overflow See other posts from Stack Overflow or by ellie
Published on 2010-05-31T00:05:39Z Indexed on 2010/05/31 0:12 UTC
Read the original article Hit count: 378

Filed under:
|
|

Hi guys! As a CSS newbie I'm wondering if it's recommended by professionals to repeat specific style attributes and their not inherited but default properties for every relevant selector? For example, should I rather use

body {background:transparent none no-repeat; border:0 none transparent; margin:0; padding:0;}
img {background:transparent none no-repeat; border:0 none transparent; margin:0; outline:transparent none 0; padding:0;}
div#someID {background:transparent none no-repeat; border:0 none; margin:0 auto; padding:0; text-align:left; width:720px; ...}

or

body {background:transparent; border:0; margin:0; padding:0;}
img {background:transparent; border:0; margin:0; outline:0; padding:0;}
div#someID {background:transparent; border:0; margin:0 auto; padding:0; text-align:left; width:720px; ...}

or just what (I think) I really need

body {background:transparent; margin:0; padding:0;}
img {border:0; outline:0;}
div#someID {margin:0 auto; width:720px; ...}

If it's best practice to go with the first or second one what do you think about defining a class like

.foo {background:transparent; border:0; margin:0; padding:0;}

and then applying it to every relevant selector:

<div id="someID" class="foo">...</div>

Yep, now I'm totally confused... so please advise! Thanks!

© Stack Overflow or respective owner

Related posts about css

Related posts about css-layout