Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS selector for other than the first child and last child

People also ask

How do I select except last child in CSS?

The :not() selector excludes the element passed to it from selection. The :last-child selector selects the last child. Combining these two above selector to excludes the last children (inner-div) of every parent div from the selection.

How do you select all the elements except the last child?

When designing and developing web applications, sometimes we need to select all the child elements of an element except the last element. To select all the children of an element except the last child, use :not and :last-child pseudo classes.

How do I select all except first child in CSS?

Use the :not(selector) Selector Not to Select the First Child in CSS. We can use the :not(selector) selector to select every other element that is not the selected element. So, we can use the selector not to select the first child in CSS.


Try:

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

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".