[drupal-devel] [bug] Zebra stripe table CSS class names are badly chosen

factoryjoe drupal-devel at drupal.org
Thu Jun 16 04:53:35 UTC 2005


Issue status update for http://drupal.org/node/25067

 Project:      Drupal
 Version:      4.6.0
 Component:    base system
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  Thox
 Updated by:   factoryjoe
 Status:       patch

I disagree with "odd" and "even" just as much as "dark" and "light".
Why? Well, with Javascript you can rearrange table rows. "Odd" and
"even" refer to relative positions within a fixed numerical order. I
would presume that when you rearrange rows, the classes are moved too
(for example, in the watchdog, the "error" class might show up on a row
and should therefore be moved with that row when sorting). So by using
the "alt method", you not only cut down on code by using /just/ the
"alt" class on every other <tr> tag, but you also get simpler markup.
Your intention, after all, is to denote alternating rows, not whether
the rows are "odd" or "even".


I also don't see any benefit in styling two different row classes; just
treat unclassed rows as the default and use the .alt class  for visual
distinction. It's that simple.




factoryjoe



Previous comments:
------------------------------------------------------------------------

June 15, 2005 - 13:58 : Thox

Attachment: http://drupal.org/files/issues/zebra-classnames.patch (1.41 KB)

The CSS class names chosen for table rows are badly chosen: "light" and
"dark". Since CSS could be used to make the "dark" rows light and the
"light" rows dark, the names are wrong. The attached patch changes
"light" and "dark" to "odd" and "even".


In the future, all class names should describe /why/ an element is
styled differently, not /how/ it is to be styled. e.g. "Red" is a bad
class name, "important" is far better.




------------------------------------------------------------------------

June 15, 2005 - 15:37 : Bèr Kessels

themes/bluemarine/style.css:13:tr.dark td, tr.light td {
themes/pushbutton/style.css:27:tr.dark td, tr.light td {
themes/pushbutton/style.css:512:#tracker tr.light, #tracker tr.dark {
themes/pushbutton/style.css:542:#forum tr.dark {


are core styles still using dark and light. jsut a quick grep.
but other than that a +1 for these better named classes.




------------------------------------------------------------------------

June 15, 2005 - 18:37 : drumm

I have a 80% finished patch on my Drupal checkout which:


- Adds <thead> and <tbody>
- Allows use of <th> in the table body.
- Unifies the classing for the block admin and permissions tables. (I
might codify this in a themeable function.)
- Removes the light class and changes the dark class to alt.
- Adds a class to the <table> tag made by theme_table() to avoid
styling conflicts with layout tables found in some themes.


Many of these changes were suggested by Chris [1].


I will be able to finish and post this patch in some number of weeks.
Please don't worry aobut submitting conflicting patches, I can deal
with it. Although we might want to decide upon odd/even and alt/[none]
classing now.
[1] http://factoryjoe.com/blog/




------------------------------------------------------------------------

June 15, 2005 - 22:12 : Steven

I'd prefer "odd"/"even" than ""/"alt". It is more descriptive.




------------------------------------------------------------------------

June 16, 2005 - 03:33 : TDobes

I agree... "odd"/"even" seems preferable.







More information about the drupal-devel mailing list