Home  »  Uncategorized   »   Selecting the Last Child in CSS

Selecting the Last Child in CSS

Posted: February 7, 2022 | by Site Host

p:last-child {
  font-size: 0.75em;
}

CSS’s last child with class. This will only work if the last child has the class .myclassName.

.myClassName:last-child {
    background: blue;
}

This will only work if the last child of #myId has the class .myclassName.

#myId .myClassName:last-child {
    background: blue;
}

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Exit mobile version