![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is it possible with CSS to have an HTML <table> such that even-numbered tr> rows have one background colour, and odd-numbered <tr> rows have another background colour? This makes wide tables easier to read. I would like this to work by applying a CSS class to only the <table element. Applying two different classes to alternate <tr> elements is undesirable, as then it would be impossible to add, delete, or sort table rows without ruining the colour alternation. |
#3
| |||
| |||
|
|
Tristan Miller <psychonaut (AT) nothingisreal (DOT) com> wrote: Is it possible with CSS to have an HTML <table> such that even-numbered <tr> rows have one background colour, and odd-numbered tr> rows have another background colour? This makes wide tables easier to read. I would like this to work by applying a CSS class to only the <table element. Applying two different classes to alternate <tr> elements is undesirable, as then it would be impossible to add, delete, or sort table rows without ruining the colour alternation. Not possible with CSS 2.x, it requires classes. It is part of CSS3, but afaik the required selectors haven't been implemented by anyone yet. |
#4
| |||
| |||
|
|
I usually let PHP build my lists/tables, and echo a class 'even' every other element. |
#5
| |||
| |||
|
|
webdevout.net |
#6
| |||
| |||
|
|
Tristan Miller <psychonaut (AT) nothingisreal (DOT) com> wrote: Is it possible with CSS to have an HTML <table> such that even-numbered tr> rows have one background colour, and odd-numbered <tr> rows have another background colour? This makes wide tables easier to read. I would like this to work by applying a CSS class to only the <table element. Applying two different classes to alternate <tr> elements is undesirable, as then it would be impossible to add, delete, or sort table rows without ruining the colour alternation. Not possible with CSS 2.x, it requires classes. |
#7
| |||
| |||
|
|
"Rik" <luiheidsgoeroe (AT) hotmail (DOT) com> wrote: webdevout.net Haven't seen that resource mentioned before. Seems like a good quality and well researched piece of work. |
#8
| |||
| |||
|
|
Greetings. In article <23a10$44e09f53$8259c69c$21633 (AT) news1 (DOT) tudelft.nl>, Rik wrote: I usually let PHP build my lists/tables, and echo a class 'even' every other element. I'm completely new to PHP; I've ordered some O'Reilly books but they are yet to arrive. Any chance you (or anyone else) could post some sample code for constructing such a table? |
#9
| |||
| |||
|
|
Greetings. In article <23a10$44e09f53$8259c69c$21633 (AT) news1 (DOT) tudelft.nl>, Rik wrote: I usually let PHP build my lists/tables, and echo a class 'even' every other element. I'm completely new to PHP; I've ordered some O'Reilly books but they are yet to arrive. Any chance you (or anyone else) could post some sample code for constructing such a table? Regards, Tristan |
#10
| |||
| |||
|
|
Spartanicus wrote: Tristan Miller <psychonaut (AT) nothingisreal (DOT) com> wrote: Is it possible with CSS to have an HTML <table> such that even-numbered tr> rows have one background colour, and odd-numbered <tr> rows have another background colour? This makes wide tables easier to read. I would like this to work by applying a CSS class to only the <table element. Applying two different classes to alternate <tr> elements is undesirable, as then it would be impossible to add, delete, or sort table rows without ruining the colour alternation. Not possible with CSS 2.x, it requires classes. Or Javascript. |
![]() |
| Thread Tools | |
| Display Modes | |
| |