How to select the second last element with CSS?

Spread the love

Sometimes, we want to select the second last element with CSS.

In this article, we’ll look at how to select the second last element with CSS.

How to select the second last element with CSS?

To select the second last element with CSS, we use the :nth-last-child selector.

For instance, we write

:nth-last-child(2) {
  //...
}

to select the 2nd last child.

Conclusion

To select the second last element with CSS, we use the :nth-last-child selector.

Leave a Reply

Your email address will not be published.