css target last child code example

Example 1: css last child

li:last-child {
    background-color: lime;
}

Example 2: remove border from last child css

.menu li:last-child {
  border: none;
}

Example 3: selecting last child css

p:last-child {
  font-size: 0.75em;
}

Example 4: apply css on last child in parent div

.parent > *:last-child {
  background-color: red;
}

Example 5: css selector last child

li:last-child {
  background-color: lime;
}

Example 6: css last child with class

/*This will only work if the last child of someEID has 
the class .myclassName 
if the last child does not have class name us js*/
#someEID .myClassName:last-child {
    background: blue;
}

Tags:

Css Example