Internet Explorer 6 :first-child :last-child problem

How to get first-child and last-child to work in IE 6

Internet Explorer 6 doesn't understand :first-child and :last-child which can be quite frustrating when dealing with your CSS. What we can do is write some jquery code that creates a first-child and last-child class names on our items.

$('ul li:first-child').not(':only-child').addClass('first-child'); $('ul li:last-child').not(':only-child').addClass('last-child'); $('ul li:only-child').addClass('only-child');

Now we can use this to our advantage and have an extra declaration in our css files.

} .menu-footer li { border-right: 1px solid #000000; } .menu-footer li:last-child, .menu-footer li.last-child { border-right: 0;

Despite the extra markup in our CSS file, this is still a very good solution as it is only needed until we stop supporting Internet Explorer 6.