A perfect code references for developers


CSS :nth-child examples


Adding a background color in css using :nth-child(odd) and :nth-child(even) order.
  • This will repeat the css background color in odd and even pattern for all "P" element under the div class group.

CSS

			.group p:nth-child(odd) {
				background: orange;
			}

			.group p:nth-child(even) {
			  background: skyblue;
			}
		
		

HTML

		

Odd Number

Even Number

Odd Number

Even Number

Odd Number

Even Number

Odd Number

Even Number

Odd Number

Even Number

Odd Number

Even Number