Use of :even and :odd pseudo-classes with list items in CSS Last Updated : 16 Dec, 2021 Comments Improve Suggest changes Like Article Like Report The:nth-child() selector in CSS is used to match the elements based on their position in a group of siblings. It matches every element that is the nth-child. The: even and: odd pseudo-class is used with the list of items such as paragraph, article items which is basically a list content. odd: The use of odd pseudo-class in any list item that will affect only the odd index number list. Syntax:li:nth-child( odd ) { // CSS Property }Example: HTML <!DOCTYPE html> <html> <head> <title> CSS :nth-child(odd) Selector </title> <!-- Style to uses :nth-child(odd) Selector --> <style> li:nth-child(odd) { background: green; font-size: 24px; color:white; } </style> </head> <body> <li>GeeksforGeeks</li> <li>A Computer Science portal</li> <li>Welcome to GeeksforGeeks</li> </body> </html> Output: even: The use of even pseudo-class in any list item that will effect only the even index number list. Syntax:li:nth-child( even ) { // CSS Property }Example: HTML <!DOCTYPE html> <html> <head> <title> CSS :nth-child(even) Selector </title> <!-- Style to uses :nth-child(odd) Selector --> <style> li:nth-child(even) { background: green; font-size: 24px; color:white; } </style> </head> <body> <li>GeeksforGeeks</li> <li>A Computer Science portal</li> <li>Welcome to GeeksforGeeks</li> </body> </html> Output: Example: This example uses both :even and :odd pseudo-class selector. HTML <!DOCTYPE html> <html> <head> <style> li:nth-child(odd) { background: green; font-size: 36px; color:white; } li:nth-child(even) { background: Blue; font-size: 36px; color:yellow; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>:even and :odd pseudo-class</h2> <li>Data Structure</li> <li>Operating System</li> <li>Computer Networks</li> <li>C Programming</li> </body> </html> Output: Supported Browsers: Google Chrome 4.0Internet Explorer 9.0Firefox 3.5Opera 9.6Safari 3.2 Comment More infoAdvertise with us Next Article Difference Between Pseudo-Classes and Pseudo-Elements in CSS S Sabya_Samadder Follow Improve Article Tags : CSS Similar Reads Difference Between Pseudo-Classes and Pseudo-Elements in CSS Pseudo-classes and pseudo-elements in CSS are selectors that allow the styling of specific states or parts of elements. Pseudo-classes target states like ': hover' or ': active', while pseudo-elements like ' ::before ' or:: after' style specific parts of an element. They enhance CSS styling by provi 2 min read Explain the concept of pseudo-elements in CSS CSS pseudo-elements are used to style specified parts of an element  and are used to add special effects to some selectors. To do this, we do not need any script like javascript to add the effects. Syntax: selector::pseudo-element { property: value; } Note: The double-colon replaced the single-colon 3 min read How to apply CSS in even childs of parent node using jQuery ? In this article, we will see how to set styles in even the child of the parent element using jQuery. To set the style on the even child of the parent, we use jQuery :nth-child(even) selector. The :nth-child(even) selector is used to select every element that is the even child of its parent element. 1 min read Explain the term âpseudo-classâ in CSS3 Cascading Style Sheets referred to as CSS is a stylesheet language used to design and describe the presentation of the webpage to make it attractive. The main use of CSS is to simplify the process of making web pages presentable.The way elements should be rendered on screen is described by CSS. CSS 4 min read Wildcard Selectors (*, ^ and $) in CSS for classes Wildcard selectors can be used with attribute selectors. The asterisk (*) matches any character, the caret (^) matches the start, and the dollar sign ($) matches the end of an attribute value. For example, .class* selects all elements with a class attribute containing "class" anywhere, .class^ selec 3 min read How to Change the Item Color of List on Hover ? In CSS, we can customize the interaction with the list element by changing the color of the list item on hover. We can also apply the different colors to each item using the :hover pseudo class in CSS. Approach: Using the :hover Pseudo-classIn this approach, we are using the :hover pseudo-class in C 2 min read Like