Ramblings about markup

wordpress

You might notice that some of the comments in the list below each post now have white backgrounds, and others have grey backgrounds. There's a story behind this. I wanted to have a fancy alternating colour scheme for the comments, so that they would have alternating white and grey backgrounds1. Fine, I thought — this should be easy. Each comment has a comment ID number, so if I write a function to check whether the ID is even or odd, I can set the class attribute of the li element to 'even' or 'odd' appropriately. Sorted.

Or not. I had forgotten that the comment IDs are assigned as each comment is made over the whole site, so that the numbers on the comments on each post are not necessarily consecutive. So instead of a nice orderly alternation, I have a distressing degree of randomness. I'm sure that there must be a way to do this properly, using the content() attribute of lists, but I can't think how. Does anyone know how, or can you point me to a helpful tutorial on the subject?

1 In the memorable words of Pete, the yellow was a bit jingly.

comments powered by Disqus