Revision 41001 of :last-child

  • Revision slug: CSS/:last-child
  • Revision title: :last-child
  • Revision id: 41001
  • Created:
  • Creator: brianloveswords
  • Is current revision? No
  • Comment one or more formatting changes

Revision Content

{{ CSSRef() }}


The :last-child pseudo-class represents any element that is the last child element of its parent.


element:last-child { style properties }


    background-color: lime;


    <span>This span is not limed.</span>
    <span>This span is! :)</span>

... should look like ...
This span is not limed. This span is! :)

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{ CompatGeckoDesktop("1") }} 9.0 9.5 3.2
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 2.1 {{ CompatGeckoMobile("1") }} 9.0 10.0 3.2


{{ languages( { "fr": "fr/CSS/:last-child", "pl": "pl/CSS/:last-child" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 name="Summary">Summary</h2>
<p>The <code>:last-child</code> <a href="/en/CSS/Pseudo-classes" title="Pseudo-classes">pseudo-class</a> represents any element that is the last child element of its parent.</p>
<h2 name="Syntax">Syntax</h2>
<pre class="eval">element:last-child { <em>style properties</em> }
<pre class="brush: css">span:last-child
    background-color: lime;
<pre class="brush: html">  &lt;div&gt;
    &lt;span&gt;This span is not limed.&lt;/span&gt;
    &lt;span&gt;This span is! :)&lt;/span&gt;
<p>... should look like ...<br> <span>This span is not limed.</span> <span style="background-color: lime;">This span is! :)</span></p>
<h2>Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>1.0</td> <td>{{ CompatGeckoDesktop("1") }}</td> <td>9.0</td> <td>9.5</td> <td>3.2</td> </tr> </tbody> </table>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Mobile</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>2.1</td> <td>{{ CompatGeckoMobile("1") }}</td> <td>9.0</td> <td>10.0</td> <td>3.2</td> </tr> </tbody> </table>
<h2 name="Notes">Notes</h2>
<p>{{ languages( { "fr": "fr/CSS/:last-child", "pl": "pl/CSS/:last-child" } ) }}</p>
Revert to this revision