0

I have plain text in my div class. Every few words in my text start from a new line but I don't have any HTML marked breaks.

I need every second line in my text to have different colors, for example: red, black, red, black... Tried everything nth-child, nothing works.

Just :first-line pseudo-element makes the first line in a different color, but this type of pseudo-element only exists for the first line.

Example:

.text {
  white-space: pre;
}
<div class="text">Hello world my name is Thomas</div>
Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62

0 Answers0