HTML and CSS Reference
In-Depth Information
Name
:nth-last-of-type( a n+ b )
Applies to:
Any element
Description:
Matches every nth child that is of the same type as the element named, with the pattern of
selection defined by the formula an+b, where aand bare <integer> s and n represents an in-
finite series of integers, countingbackwardfromthelastsuchelement. Thus, to select every
third-to-last paragraph ( p ) that is a child of the body element, starting with the first such para-
graph, 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 an+bformula, there are two keywords permitted: even and odd . These are
equivalent to 2n and 2n+1 , respectively.
Examples:
td:nth-last-of-type(even) {background-color: #FCC;}
img:nth-last-of-type(3n) {float: left; border: 2px solid;}
Search WWH ::




Custom Search