Select all elements after specific element

I want to apply some specific styles to all elements which come after a certain element. For example, I want to select all elements which come after divider and change their background color to green.

<ul>
  <li> Cricket </li>
  <li> Hockey </li>
  <li class='divider'> </li> //Divider here
  <li> Football </li>
  <li> Table Tennis </li>
</ul>

CSS code

li {
  background-color: 'red';
}

//Selector to select elements after divider {
  background-color: 'green';
}

Answers


You can use

.divider ~ li {
    background-color:green;
}

Need Your Help

Validate IBAN PHP

php validation iban

As designing a new platform we tried to integrate the IBAN numbers. We have to make sure that the IBAN is validated and the IBAN stored to the database is always correct. So what would be a proper ...

Find hidden dependencies in Ivy

java log4j ivy dependency-management

I'm using Apache Ivy + IvyDE for getting my project's dependencies, which are: