title: CSS: last-child of parent
body: <p><code>:last-child</code> works great when all of the "children" elements are the same (ie: all <code>&lt;p&gt;</code>'s or all <code>&lt;li&gt;</code>'s and the rule is applied to that type of child.</p>
  
  <p>But how can I use CSS to select the last "child" element inside a parent which contains varying elements?</p>
  
  <p>For instance, in this example, how could I apply a rule to the <code>.parent</code> to select the last object inside of it (the <code>div</code>)?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.parent:last-child {
    background-color: red;
   }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="parent"&gt;
    
    &lt;p&gt;First child&lt;/p&gt;
    &lt;input type="text" placeholder="Second child" /&gt;
    &lt;div&gt;Third child&lt;/div&gt;
    
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>