I'm having trouble using CSS to hide the first .sku
element within an aside
that contains two of these elements. Strangely, the :last-child
selector works just fine. Can anyone explain why this might be happening? Here's a link to the JSFiddle for reference.
HTML
<aside>
<h1>Product Name</h1>
<div class="sku">
<h3>
100 – Small
</h3>
<div class="dimension">
<ul>
<li>
<span class="title">
Product Dimensions
</span>
<span class="specs">
23.75w
x
17.75h
x
28d
</span>
</li>
</ul>
</div>
</div>
<div class="sku">
<h3>
200 – Large
</h3>
<div class="dimension">
<ul>
<li>
<span class="title">
Product Dimensions
</span>
<span class="specs">
29.75w
x
17.75h
x
28d
</span>
</li>
</ul>
</div>
</div>
</aside>
CSS
.sku:first-child {
display:none !important; /*doesn't hide the first child*/
}
.sku:last-child {
display:none !important; /*does hide the first child*/
}
Can someone shed light on why :first-child
is not selecting the first div as expected?