I agree. Apply generic styles to a class, then add html tags as you go. This
avoids problems with specificity. The div.container class has a greater
specificity than the .container class,  If both classes have the same
styles, the div.container class will override .container.



On 1/26/07, Michael Turnwall <[EMAIL PROTECTED]> wrote:

I have a co-worker, that whenever he creates a class, puts "div" in front
of it if the class is being assigned to a div. Here's an example:

*div.container {*
*background-color: #fff;*
*margin-bottom: 18px;*
*}*
*
*
*div.container div.container_inner {*
*border: 1px solid #bbb;*
*margin-left: 8px;*
*}*
*
*
*div.container div.inset {*
*padding: 3px;*
*}*

As you can see, the code can get messy rather quickly. He says he does it
to avoid conflicts. My argument is that you should only do that when you
specifically want the class only to apply to a div. If I want to use the
class on another element I can't without creating a new rule. I would think
the better way would be to create the class without the "div." part first
and in the future add the "div." part if I need to be more specific. This
allows the CSS to be more generic and cleaner.

Any thoughts? Do you think the above code is good, bad, doesn't matter and
why


*--Michael Turnwall*
visit me at *turnwall.net* <http://turnwall.net>



*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to