Revision 319397 of :last-of-type

  • Revision slug: CSS/:last-of-type
  • Revision title: :last-of-type
  • Revision id: 319397
  • Created:
  • Creator: matt_basta
  • Is current revision? No
  • Comment The example here was terrible because it had the same effect as using :last-child, which is confusing.

Revision Content

{{ CSSRef() }}


The :last-of-type CSS pseudo-class represents the last sibling of the given type in the list of children of its parent element.


element:last-of-type { style properties }


To match the last em element inside a p element, you can use this:

p em:last-of-type {
  color: lime;
  <em>I'm not lime :(</em>
  <em>I'm lime :D</em>
  <strong>I'm not lime :(</strong>
  <strong>I'm also not lime :(</strong>


Specification Status Comment
{{ SpecName('CSS4 Selectors', '#last-of-type-pseudo', ':last-of-type') }} {{ Spec2('CSS4 Selectors') }} No change.
{{ SpecName('CSS3 Selectors', '#last-of-type-pseudo', ':last-of-type') }} {{ Spec2('CSS3 Selectors') }} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{ CompatGeckoDesktop("1.9.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.1") }} 9.0 10.0 3.2

See also

  • {{ Cssxref(":nth-last-of-type") }}
  • {{ Cssxref(":first-of-type") }}
  • {{ Cssxref(":nth-of-type") }}
  • CSS3 Reference

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>:last-of-type</code> <a href="/en/CSS/Pseudo-classes" title="Pseudo-classes">CSS pseudo-class</a> represents the last sibling of the given type in the list of children of its parent element.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="eval">
element:last-of-type { <em>style properties</em> }
<h2 id="Example" name="Example">Example</h2>
<p>To match the last <font face="Courier New, Andale Mono, monospace"><span style="line-height: normal;">em&nbsp;</span></font>element inside a <code>p</code> element, you can use this:</p>
<pre class="brush: css">
p em:last-of-type {
&nbsp; color: lime;
<pre class="brush: html">
&nbsp; &lt;em&gt;I'm not lime :(&lt;/em&gt;
  &lt;em&gt;I'm lime :D&lt;/em&gt;
&nbsp; &lt;strong&gt;I'm not lime :(&lt;/strong&gt;
&nbsp; &lt;strong&gt;I'm also not lime :(&lt;/strong&gt;
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
      <td>{{ SpecName('CSS4 Selectors', '#last-of-type-pseudo', ':last-of-type') }}</td>
      <td>{{ Spec2('CSS4 Selectors') }}</td>
      <td>No change.</td>
      <td>{{ SpecName('CSS3 Selectors', '#last-of-type-pseudo', ':last-of-type') }}</td>
      <td>{{ Spec2('CSS3 Selectors') }}</td>
      <td>Initial definition.</td>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <td>Basic support</td>
        <td>{{ CompatGeckoDesktop("1.9.1") }}</td>
<div id="compat-mobile">
  <table class="compat-table">
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
        <td>Basic support</td>
        <td>{{ CompatGeckoMobile("1.9.1") }}</td>
<h2 id="See_also" name="See_also">See also</h2>
  <li>{{ Cssxref(":nth-last-of-type") }}</li>
  <li>{{ Cssxref(":first-of-type") }}</li>
  <li>{{ Cssxref(":nth-of-type") }}</li>
  <li><a class="external" href="">CSS3 Reference</a></li>
Revert to this revision