How to select the first occurring element after another element with CSS?

Spread the love

Sometimes, we want to select the first occurring element after another element with CSS.

In this article, we’ll look at how to select the first occurring element after another element with CSS.

How to select the first occurring element after another element with CSS?

To select the first occurring element after another element with CSS, we use the + selector.

For instance, we write

#many .more.selectors h4 + p {
}

to select the first p element after the h4 element that’s in the element with the more and selectors classes which is in the element with ID many.

Conclusion

To select the first occurring element after another element with CSS, we use the + selector.

Leave a Reply

Your email address will not be published.