Style category link depending on category ID

I want to style a link depending on its ID, for instance, if the category ID is 2, then I want the link to be pink. My theme calls the category like this:

<?php if (in_array('categories', get_option('theme_postinfo2'))) { ?> <?php the_category(', ') ?>

I found a way to style specific categories in lists by adding:

Read More
li.cat-item-7 { ... }  /* category ID #7, etc */

to my stylesheet, however, I cannot find a way to do the same thing to links. What type of solutions are available? Please be detailed in your reply as my coding knowledge is limited.

Related posts

Leave a Reply

1 comment

  1. the basic way is to

     #li.cat-item-7
        { color: red; }
    

    Now, change ‘7’ to the number you want, as many times as you want and ‘red’ to the color you want for that category like –

     #li.cat-item-2
        { color: pink; }
    
        #li.cat-item-8
        { color: green; }