[themes] <div id= vs <div class=

Cristian Palmas cristian.palmas at gmail.com
Thu Mar 3 17:53:39 UTC 2011


2011/3/3 Nat Meysenburg <nat at openflows.com>

> It is not an either or proposition, you can use both ids and classes on
> elements. Generally, it is a good idea to do both. Drupal code by
> default does on many things.
>
> In your case for instance you would want something like <div id="menu-1"
> class="menu-bar", <div id="menu-2" class="menu-bar".
>
> Then you can do .menu-bar for general styles and #menu-1 for styles
> specific to that menu.
>
> Hope that is helpful,
> ~~nat
> _______________________________________________
> themes mailing list
> themes at drupal.org
> http://lists.drupal.org/mailman/listinfo/themes
>

There are different opinions about the use of ids or classes, even among the
major designers.
Anyway, in general, if you have to identify a specific block of content or
tag, it's more useful to use ids. Use meaningful names for semantic reasons
(#article, #aside, #navbar or #nav, #navigation).
Instead, it's better to use classes for blocks of content or tags that
behave the same way (.node, .block, .inner...)
For instance:

<div id="page">
      <div id="column1" class="float-left"></div>
     <div id="column2" class="float-left"></div>
     <div id="column2" class="float-left"></div>
     <div id="footer" class="easyclear"></div>
</div>

-- 
~ Cristian Palmas ~
http://www.cristianpalmas.it

Chi vuole davvero realizzare i propri sogni, si sveglia all'alba

One who really wishes to realize his own dreams, wakes up at dawn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/themes/attachments/20110303/333e855f/attachment.html 


More information about the themes mailing list