If there are other elements that are not a div
with the same class, when using the div.classe1{}
information, the class will only be applied to the element that is a div
, and will not be applied to other elements ( p
, span
, for example).
I particularly prefer to use div.classe1{}
, because when I view the CSS code, I can see more quickly that that class is being applied to one or more elements that are div
.
In cases where CSS grows with many classes, I think it's better.
If you are going to use this class in just one div, it would be better to create a id
for the div, and use the rule just for it, like this:
No HTML:
<div id="minhadiv">Teste</div>
In CSS:
#minhadiv { .... }
This way you apply the rule directly to the specific div with this id
.