How to select the next element with CSS?

Spread the love

Sometimes, we want to select the next element with CSS.

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

How to select the next element with CSS?

To select the next element with CSS, we can use the adjacent sibling selector.

For instance, we write

h1.hc-reform + p {
  clear: both;
}

to select the p element that’s next to the h1 element with class hc-reform.

Conclusion

To select the next element with CSS, we can use the adjacent sibling selector.

Leave a Reply

Your email address will not be published.