# How can I add a custom class to every 2nd message?

**URL:** <https://meta.discourse.org/t/how-can-i-add-a-custom-class-to-every-2nd-message/49990>\
**Category:** Support\
**Created:** [9월 11, 2016, 7:37오후 UTC](https://meta.discourse.org/t/how-can-i-add-a-custom-class-to-every-2nd-message/49990 "2016-09-11T19:37:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)\
**Post date:** [9월 11, 2016, 7:48오후 UTC](https://meta.discourse.org/t/how-can-i-add-a-custom-class-to-every-2nd-message/49990/2 "2016-09-11T19:48:58Z")

</div>

Hi ziptofaf welcome to the forum

I’m not convinced that any class attributes need to be inserted into the DOM and I think there is a good chance that satisfactory results can be obtained purely by using the correct CSS selectors.

For example, this “works” somewhat except “small action” posts may make it a bit off from what you’re wanting.

```plaintext
div.post-stream > div:nth-child(odd) {
  background-color: #bde;
}

```

---

_[View the full topic](https://meta.discourse.org/t/how-can-i-add-a-custom-class-to-every-2nd-message/49990)._
