Selecting all But the First Custom Element

Ole Ersoy
1 min readSep 9, 2020

--

Image by analogicus from Pixabay

Scenario

We have multiple custom elements in a container like this:

<app-header-selection></app-header-selection>
<app-header-selection></app-header-selection>

We want a CSS selector that selects all but the element, so that we can space the remaining elements by 2rem .

Approach

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

--

--

Ole Ersoy

Founder of Firefly Semantics Corporation