Last-child issues. Please help

Hi everyone!

I’m having a problem with my CSS.

This works:

.someclass:last-child {
    border-top: 1px solid blue
    } 

This doesn’t:

#myform .someclass:last-child {
    border-top: 1px solid blue
    } 

I have a form consisting of a number of divs with a class of “someclass”. I’d like to style the last div, but for some reason it’s not working (no border appears).

Anyone know why?

Thanks in advance for any assistance.

So little CSS and no HTML.

Can you post a link to the page?

Yes, we can’t tell why it’s not working without seeing the HTML. If the last .someclass div is lot the last child of the element with the #myform ID, then it won’t be targeted.

The markup is needed, especially with a STRUCTURAL PSEUDO class like :last-child

some off the top suggestions:

  • check that you actually HAVE an ancestor element that had ID=‘myform’ ( am assuming that was supposed to be the ID of your FORM tag,
  • check that your element is actually THE LAST ELEMENT within this and not just the last element with the given class

Hi ronpat, ralph.m and dresden_phoenix,

thanks to all of your help.

I ended up having to wrap all of my “someclass” divs in another div, otherwise the border would not appear because of the input tag to submit the form. So, problem solved.

Thanks again.