Want to share your CSS expertise with others? Apply to the MDN Fellowship by April 1! http://mzl.la/MDNFellowship


Revision 302329 of :last-of-type

  • Revision slug: CSS/:last-of-type
  • Revision title: :last-of-type
  • Revision id: 302329
  • Created:
  • Creator: jsalinas
  • Is current revision? No
  • Comment Fix example description

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 strong element inside a p element, you can use this:

p strong:last-of-type {
  color: lime;
  <em>I'm not lime :(</em>
  <strong>I'm not lime :(</strong>
  <strong>I'm lime :D</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 <code>strong</code> element inside a <code>p</code> element, you can use this:</p>
<pre class="brush: css">
p strong:last-of-type {
&nbsp; color: lime;
<pre class="brush: html">
&nbsp; &lt;em&gt;I'm not lime :(&lt;/em&gt;
&nbsp; &lt;strong&gt;I'm not lime :(&lt;/strong&gt;
&nbsp; &lt;strong&gt;I'm lime :D&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="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#last-of-type-pseudo">CSS3 Reference</a></li>
Revert to this revision