CSS selector for other than the first child and last child

HtmlCssCss Selectors

Html Problem Overview


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;
}

Html Solutions


Solution 1 - Html

Try:

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

Solution 2 - Html

Sure it will work, you just have to use two 'not' selectors.

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

It will continue down the line after the first one, saying "not the first child" and "not the last child".

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDanielView Question on Stackoverflow
Solution 1 - HtmlSalman von AbbasView Answer on Stackoverflow
Solution 2 - HtmlanimusonView Answer on Stackoverflow