:nth-last-of-type(* a*n+

`b`

Any element

Matches every nth child that is of the same type as the element named, with the
pattern of selection defined by the formula
*a*n+*b*, where
*a* and *b* are `<integer>`

s and n represents an
infinite series of integers, *counting backward from the last
such element*. Thus, to select every third-to-last paragraph
(`p`

) that is a child of the `body`

element, starting with the first such
paragraph, you write ```
body >
p:nth-last-of-type(3n+1)
```

. This holds true even if other
elements are interspersed between the various paragraphs, such as
lists, tables, or other
elements.

In place of the *a*n+*b*
formula, there are two keywords permitted: `even`

and `odd`

. These are equivalent to `2n`

and `2n+1`

, respectively.

td:nth-last-of-type(even) {background-color: #FCC;} img:nth-last-of-type(3n) {float: left; border: 2px solid;}

Start Free Trial

No credit card required