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.
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.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With