is there a method in css to select all but the last list item in a particular class? I am using css to add a character between the navigation in wordpress. But it adds the character after every link. I want to remove the character from the last link only.
okay, I tried it and this is what happened. I am working in wordpress. I am adding a character in between the navigation. Every time you add a new menu item, it automatically adds the character. So I had to add php code to the wp_nav_menu function to get it to add the image between the nav, so it looks like this
I think you may have misunderstood what I meant when I said "easier" (I should have explained). It's easier for the browser to target the first child and also easier to get it working on most browsers. :last-child is very heavy compared to :first-child or element + element and the latter works on IE7+, whereas :first-child works on IE8+ and :last-child only works on IE9. (these work on the latest versions of all other major browsers such as Chrome, Firefox, Opera, Safari)
If you don't mind ignoring IE then :last-child is fine, however, if you want to include it then I suggest element + element or :first-child
#list li + li{background: red !important!;}
Try that, itshould make all backgrounds red except the first and you can work on it from there.
That will place a border to the left of every list item except the first. This will work in IE7+
Instead of having the character that you want to add come after the navigation, have it come before the navigation, but exclude the first one.
now I tried the fix and it messes up the nav. I tried like this
it doesn't work. This is what I ended up getting to work
I understand now what you were saying jamy, it would be easier but I can't get it to work
If you don't mind ignoring IE then :last-child is fine, however, if you want to include it then I suggest element + element or :first-child
Try that, itshould make all backgrounds red except the first and you can work on it from there.