
Originally Posted by
Chris77
So it's better to use .classname in css and not
div.someclass{...}
h1.someclass{...}
span.classname{...}
(but might be a little more difficult for readability of a css file).
No, it's not about that, since you can't cram in one CSS rule all the declarations for all the div, h1, span with same class and get away with it, for many reasons, including the fact that div may have different styling from the h1, and span can demand some other styling that's not fitted for any div or h1, and that you normally would put in .class{} the common declarations, and in div.class{} those specific for div, in h1.class{} those specific for h1 and in span.class{} those specific for span, meaning you are forced to have all four: .class{}, div.class{}, h1.class{}, span.class{}, thus making your question about choosing between (.class{}) and (div.class{}, h1.class{}, span.class{}) futile.
It's better to not use the same class name for different classes of tags. There is no reason to do that.
This is what you should do
Code:
HTML
<div class="someclass"...
<h1 class="someotherclass"...
<span class="someothercompleteyldifferentclass"...
and this means you can lose the tag prefix, and have just that:
Code:
CSS
.someclass{...}
.someotherclass{...}
.someothercompleteyldifferentclass{...}

Originally Posted by
Chris77
So when would it be wise to use p.classname instead of .classname ?
Never.
Bookmarks