Setting aside that you’re incorrectly using query_posts()
, the easiest solution is to add a call to post_class()
, to output post-specific classes, including .category-{ID}
and .category-{slug}
:
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<li <?php post_class(); ?>><a href="https://wordpress.stackexchange.com/questions/123066/<?php the_permalink(); ?>" title="<?php the_title(); ?>"><strong><?php the_title(); ?></strong></a><br />
<em><?php echo substr(get_the_excerpt(), 0,110); ?> ...</em>
</li>
<br />
<?php endwhile; ?>
Then, you can use CSS to target li.category-{ID}
.