:nth-last-of-type() Back
- The
:nth-last-of-type()
is a CSS pseudo-class selector that allows you to select elements of the same type based on their index (source order) inside their container, starting from the last element upwards. - It's more specific than
nth-last-child()
. - You can also pass positive number, predefined keywords(even, odd) and formula to
nth-last-of-tpye()
likenth-last-child()
.
Case: learning :nth-last-of-type()
See the Pen BjbNmx by aleen42 (@aleen42) on CodePen.
Note
- Using some tools to help dealing with the calculations for
nth-child
by visualizing.- CSS3 structural pseudo-class selector tester by Lea Verou
- NTH-TEST – nth-child and nth-of-type tester by Paul Maloney
- There is a pseudo-class selector that has a similar functionality to that of :nth-last-of-type(), that selector is the :nth-of-type() selector. :nth-of-type() is similar to :nth-last-of-type(), except that instead of iterating through the elements from the last one, it starts iterating from the first one downwards.