This page is part of the CSS3.info CSS selectors test. See more info on CSS3 selectors.
div div:nth-last-of-type(1) {
}
<div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should match the marked element, because it is the last and only child of the correct type
div div:nth-last-of-type(0n+1) {
}
<div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should match the marked element, because it is the last and only child of the correct type
div div:nth-last-of-type(1) {
}
<div>
<div></div>
<div></div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should match the marked element, because it is the last child of the correct type
div div:nth-last-of-type(0n+1) {
}
<div>
<div></div>
<div></div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should match the marked element, because it is the last child of the correct type
div div:nth-last-of-type(2) {
}
<div>
<div></div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div></div>
</div>
The CSS selector should match the marked element, because it is the second child from the bottom of the correct type
div div:nth-last-of-type(0n+2) {
}
<div>
<div></div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div></div>
</div>
The CSS selector should match the marked element, because it is the second child from the bottom of the correct type
div div:nth-last-of-type(1n) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div>Does this element match?</div>
<div>Does this element match?</div>
</div>
The CSS selector should match all marked elements, because every element of the correct type should match
div div:nth-last-of-type(n) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div>Does this element match?</div>
<div>Does this element match?</div>
</div>
The CSS selector should match all marked elements, because every element of the correct type should match
div div:nth-last-of-type(n+1) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
</div>
The CSS selector should match all marked elements, because every element of the correct type should match
div div:nth-last-of-type(1n+1) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div>Does this element match?</div>
<div>Does this element match?</div>
</div>
The CSS selector should match all marked elements, because every element of the correct type should match
div div:nth-last-of-type(n+2) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div></div>
</div>
The CSS selector should match all marked elements, because every element of the correct type before the second from the bottom should match
div div:nth-last-of-type(1n+2) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div></div>
</div>
The CSS selector should match all marked elements, because every element of the correct type before the second from the bottom should match
div div:nth-last-of-type(even) {
}
<div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should match all marked elements, because every even element of the correct type counting from the bottom should match
div div:nth-last-of-type(odd) {
}
<div>
<div></div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should match all marked elements, because every odd element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n) {
}
<div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should match all marked elements, because every even element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n-1) {
}
<div>
<div></div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should match all marked elements, because every odd element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n+0) {
}
<div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should match all marked elements, because every even element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n+1) {
}
<div>
<div></div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should match all marked elements, because every odd element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n+2) {
}
<div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should match all marked elements, because every even element of the correct type counting from the bottom should match
div div:nth-last-of-type(3n+1) {
}
<div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
<div></div>
<div>Does this element match?</div>
</div>
The CSS selector should match all marked elements, because every third element of the correct type should match counting from the first from bottom
div div:nth-last-of-type(-n+2) {
}
<div>
<div></div>
<div></div>
<blockquote></blockquote>
<div>Does this element match?</div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should match all marked elements, because the last two elements of the correct type should match
div div:nth-last-of-type(0) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
</div>
The CSS selector should not match the marked elements, because it should match no elements at all
div div:nth-last-of-type(0n+0) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
</div>
The CSS selector should not match the marked elements, because it should match no elements at all
div div:nth-last-of-type(1) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because it should only match the last element of the correct type
div div:nth-last-of-type(0n+1) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because it should only match the last element of the correct type
div div:nth-last-of-type(2) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
<div>Does this element match?</div>
</div>
The CSS selector should not match the marked elements, because it should only match the second element of the correct type from the bottom
div div:nth-last-of-type(0n+2) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
<div>Does this element match?</div>
</div>
The CSS selector should not match the marked elements, because it should only match the second element of the correct type from the bottom
div div:nth-last-of-type(n+2) {
}
<div>
<div></div>
<div></div>
<div></div>
<blockquote></blockquote>
<div>Does this element match?</div>
</div>
The CSS selector should not match the marked element, because every element starting from the second of the correct type from the bottom should match
div div:nth-last-of-type(1n+2) {
}
<div>
<div></div>
<div></div>
<div></div>
<blockquote></blockquote>
<div>Does this element match?</div>
</div>
The CSS selector should not match the marked element, because every element starting from the second element of the correct type from the bottom should match
div div:nth-last-of-type(even) {
}
<div>
<div></div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because every even element of the correct type counting from the bottom should match
div div:nth-last-of-type(odd) {
}
<div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because every odd element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n) {
}
<div>
<div></div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because every even element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n-1) {
}
<div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because every odd element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n+0) {
}
<div>
<div></div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because every even element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n+1) {
}
<div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because every odd element of the correct type counting from the bottom should match
div div:nth-last-of-type(2n+2) {
}
<div>
<div></div>
<div>Does this element match?</div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because every even element of the correct type counting from the bottom should match
div div:nth-last-of-type(3n+1) {
}
<div>
<div></div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div>Does this element match?</div>
<div></div>
</div>
The CSS selector should not match the marked elements, because every third element of the correct type counting from the first of the bottom should match
div div:nth-last-of-type(-n+2) {
}
<div>
<div>Does this element match?</div>
<div>Does this element match?</div>
<blockquote></blockquote>
<div></div>
<div></div>
<blockquote></blockquote>
</div>
The CSS selector should not match the marked elements, because only the last two elements of the correct type should match
div div:nth-last-of-type(1) {
}
<div>
<div id='insertAfter'></div>
</div>
var ib = document.getElementById('insertAfter');
ib.parentElement.appendChild(document.createElement("div"));
The CSS selector should match the div element that is inserted by the Javascript code.
div div:nth-last-of-type(1) {
}
<div>
<div id='insertAfter'></div>
</div>
var ib = document.getElementById('insertAfter');
ib.parentElement.appendChild(document.createElement("div"));
The original div element should not be a match for the :nth-last-of-type() selector.