Search code examples
htmlcssangularcss-selectorsweb-component

Styling all but the first selected element?


I'm selecting custom elements like this:

app-csv-header-selection {
    margin-left: 2rem;
}

And that works fine. I'd also like to exclude the styling from the first element selected.

Is this possible without also involving a parent container?

A pseudo example would be something like:

app-csv-header-selection:not(:first) {
    margin-left: 2rem;
}

Solution

  • app-csv-header-selection:not(:first-of-type) {
            margin-left: 2rem;
    }
    

    Works. The reason for using first-of-type is to make sure only app-csv-header-selection elements are included in the selection.