It seems the CSS pseudo-class :last-child
doesn't work on form elements, but :first-child
does.
form:first-child {
border: 1px solid blue;
}
form:last-child {
border: 1px solid red;
}
<body>
<form>
<p>First Form</p>
</form>
<form>
<p>Second Form</p>
</form>
</body>
I'm only interested in styling the form element itself and I've only tested this in Chrome. The first form gets a blue background and the second gets no background. Chrome's inspector doesn't show :last-child
applied to the second form either. So how does one select the last form using CSS?