Right, so this is strange. This code works as expected:
HTML:
<section>
Section #1
</section>
<section>
Section #2
</section>
<section>
Section #3
</section>
CSS:
section{
margin-right: 30px;
}
section:last-child{
margin-right: 0;
}
The first two sections get a right margin of 30px, while the third section doesn't get a right margin.
Now, if I add a footer element after the last section, the :last-child will be ignored. That way, all three sections will have a right margin of 30px. This holds true in both Mozilla and Webkit.
Has anyone got a clue why this is, and how it can be fixed?
Thanks!
- Erik