DEV Community

chiebukaaustin
chiebukaaustin

Posted on

General Sibling Combinator

The general sibling combinator (~), is a great way to avoid using unnecessary divs when styling your HTML file. It used used to select elements that are siblings of another element, in other words, defined elements that come after or precede another defined element. For example:

p ~ ol {
background-color: yellow;
}

This would give every ordered list element that are preceded by a paragraph element a background color of yellow

Top comments (0)