CSS selector for other than the first child and last child

Daniel picture Daniel · Oct 17, 2011 · Viewed 65.1k times · Source

I am making a very advanced website. My question: Is it possible to select all the other children except for the :first-child and the :last-child? I know there is a :not() selector but it doesn't work with more than one not in the parentheses. This is what I have:

#navigation ul li:not(:first-child, :last-child) {
    background: url(images/[email protected]);
    background-size: contain;
}

Answer

Salman von Abbas picture Salman von Abbas · Oct 17, 2011

Try:

#navigation ul li:not(:first-child):not(:last-child) {
  ...
}