Enter your keyword

How To Alternate Colors (Or Other Styles) On Comments In WordPress

How To Alternate Colors (Or Other Styles) On Comments In WordPress

Ever noticed how it’s kind of hard to keep track of comments when they’re all one color? For example, look at my comment section on ABDPBT:

All of the comments are set to the same background, font styles, et cetera, except for my own, which appear in their own background color. But what if I wanted to make it so that the colors alternated with each comment? Here’s a way to set up your comment section to alternate colors (or other styles) so that it’s a snap to determine where one person’s comment ends and another starts. If you’re using a recent version of WordPress (after 2.7, in other words), all you have to do is alter the CSS with the following code (since I’m using Thesis, I’m going to put it in my custom.css file):

.odd {
background: white;
color: black;
.even {
background: black;
color: white;

I’ll change some colors around to make things a bit less dramatic:

.odd {
background: #EFEFEF;
.even {
background: #FFFFFF;
color: #111111;

NOTE: If you’re using an older version of WordPress, you’ll have to set up an alternating set of classes for yourself in order to get it to work. First, open up your comments.php file and modify the comments loop as follows:

  • >

then you can adjust the style as shown above. Play around with different colors and styles until you get something you like. Done!

For older versions of wordpress, you’ll have to set up a custom class of your own. Here’s the code to add to your

Comments (7)

  1. Alexis
    Jun 9, 2010

    Thanks for the tutorial. I was wondering if you could please share how you styled the huge comment numbers you have. I’m a complete Thesis noob, still getting the hang of hooks, and can’t seem to figure this out. Thanks so much.

  2. Jun 9, 2010

    Hi Alexis,

    Sure. I’ve actually written a post on it in case anybody else is looking for the same thing. It’s a pretty easy fix. Try it and let me know if it needs any additional fixing for your particular install, because sometimes there will be some CSS somewhere that is slightly different that leads to something getting messed up somewhere. Here’s the link:


  3. Alvin
    Aug 24, 2010

    Nice tut!
    Is this also possible for the homepage posts ?

    It seems pretty easy , but i am not an wp expert 🙁


  4. Zackary Kava
    Jul 27, 2017

    I’ve recently started a web site, the info you offer on this website has helped me greatly. Thank you for all of your time & work.


  5. Marilee Wender
    Aug 1, 2017

    Pretty great post. I just stumbled upon your blog and wanted to mention that I’ve really loved surfing around your blog posts. After all I will be subscribing on your feed and I’m hoping you write again very soon!


  6. Far cry
    Dec 3, 2017

    hi. I observe you are focused on creating backlinks and stuff. I’m selling scrapebox auto approve lists. Do you want to trade ?


  7. Ladonna Talleut
    Dec 31, 2017

    Thank you for all your valuable hard work on this site. My daughter enjoys engaging in research and it’s easy to see why. We all learn all concerning the lively medium you present efficient ideas via your web blog and improve response from other individuals on that subject matter while our own girl is without a doubt discovering a whole lot. Take pleasure in the remaining portion of the year. You are performing a superb job.


Post a Comment

Your email address will not be published.