Posted inCSS

even child css – Selecting elements using CSS :nth-child() method

even child css – CSS :nth-child(n) selector matches only nth child element of its parent element.

even child css – CSS :nth-child() Selector

The:nth-child() selector in CSS is used to match the elements based on their position in a group of siblings. We can even select elements that are not really there.

p:nth-child(2) {
  background: red;
}
p:nth-child(odd) {
  background: red;
}

p:nth-child(even) {
  background: green;
}

Example

  • Pakainfo
  • Pakainfo
  • Pakainfo
  • Pakainfo
  • Pakainfo

CSS Code

li {
    color: red;
}
li:nth-child(odd) {
    color: #3d3d3d;
}
li:nth-child(even) {
    color: pink;
}

select even child css

css odd even child

tr:nth-child(even) {background: #3d3d3d}
tr:nth-child(odd) {background: #c60000}

nth-child() css

/* Selects the second 
  • element in a list */ li:nth-child(2) { color: lime; } /* Selects every fourth element among any group of siblings */ :nth-child(4n) { color: lime; }
  • Don’t Miss : How To Get Nth-Child Selector Using Jquery?

    select odd child css
    Selects only odd elements

    li:nth-child(odd) { 
        color: pink;   
    }
    

    select even child css
    /* Selects only even elements */

    li:nth-child(even) { 
        color: blue;   
    }
    

    I hope you get an idea about even child css.
    I would like to have feedback on my infinityknow.com.
    Your valuable feedback, question, or comments about this article are always welcome.
    If you enjoyed and liked this post, don’t forget to share.

    I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype