šŸ“• Build AI Agents using LangGraph.js is now out!

CSS – select all elements between two classes

Let's see how we can write a CSS selector that targets all elements between two classes.

Take the below example:
CSS - select all elements between two classes

We want to add a background color to all the elements between the .start and .end classes.

Below is the CSS selector that does this:

/* Select all  the elements between 
the .start and .end classes */
.start ~ :not(.end,.end ~ *) {
    background-color: orangered;
}

And this is the result:
CSS - select all elements between two classes

The way how this selector work is by selecting all sibling elements that come after an element with a class of .start but do not have a class of .end or any element that comes after an element with a class of .end.

As usual, you can check out the full code on Github and see the live example here.

Happy CSS styling, folks!

šŸ“– Build a full trivia game app with LangChain

Learn by doing with this FREE ebook! This 35-page guide walks you through every step of building your first fully functional AI-powered app using JavaScript and LangChain.js

šŸ“– Build a full trivia game app with LangChain

Learn by doing with this FREE ebook! This 35-page guide walks you through every step of building your first fully functional AI-powered app using JavaScript and LangChain.js


Leave a Reply

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