:nth-last-child

  • Revision slug: CSS/:nth-last-child
  • Revision title: :nth-last-child
  • Revision id: 57504
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment new page

Revision Content

{{ CSSRef() }} {{ Fx_minversion_header("3") }}

Summary

The :nth-last-child pseudo-class matches an element that has <tt>an+b-1</tt> siblings after it in the document tree, for a given positive or zero value for <tt>n</tt>, and has a parent element. See {{ Cssxref(":nth-child") }} for a more thorough description of the syntax of its argument.

Syntax

element:nth-last-child(an + b) { style properties }

Examples

Example selectors

<tt>tr:nth-last-child(-n+4)</tt>
Matches the last four rows of an HTML table.
<tt>span:nth-last-child(even)</tt>
Matches the even elements in their parent element, starting at the last element and working backward.

See also

Revision Source

<p> {{ CSSRef() }}
{{ Fx_minversion_header("3") }}
</p>
<h3 name="Summary"> Summary </h3>
<p>The <code>:nth-last-child</code> pseudo-class matches an element that has <tt><i>a</i>n+<i>b</i>-1</tt> siblings after it in the document tree, for a given positive or zero value for <tt>n</tt>, and has a parent element. See {{ Cssxref(":nth-child") }} for a more thorough description of the syntax of its argument.
</p>
<h3 name="Syntax"> Syntax </h3>
<pre class="eval">element:nth-last-child(<i>a</i>n + <i>b</i>) { <i>style properties</i> }
</pre>
<h3 name="Examples"> Examples </h3>
<h4 name="Example_selectors">Example selectors</h4>
<dl><dt><tt>tr:nth-last-child(-n+4)</tt>
</dt><dd>Matches the last four rows of an HTML table.
</dd><dt><tt>span:nth-last-child(even)</tt>
</dt><dd>Matches the even elements in their parent element, starting at the last element and working backward.
</dd></dl>
<h3 name="See_also"> See also </h3>
<ul><li> {{ Cssxref(":nth-child") }}
</li><li> <a class="external" href="http://www.w3.org/TR/css3-selectors/#nth-last-child-pseudo">CSS3 Reference</a>
</li></ul>
Revert to this revision