Below is my html structure
To build on the other guys answers, an alternative could be to use javascript to fill the gaps, selectivizr is a good example of adding last-child support.
http://selectivizr.com/
Where did you read that? :first-child
is supported back to IE7, but :last-child
is IE9 and later.
(Headers moved down for your convenience)
I know its old but...there is a simple way to do it:
Just in the li you want the change do this:
<li style="yourstyle;">
...</li>
Try to use something like that:
.footerMenu li {background-color: expression(this.previousSibling==null?'red':'green');}
You read it wrong. It says that it's not supported in IE8:
If you were looking at :first-child
, which does have support in IE7 and IE8, and thinking that the same applies to :last-child
... surprise! It doesn't.
:first-child
is a CSS2 selector, but :last-child
was only introduced in CSS3, so since Microsoft was only aiming for CSS2.1 compliance with IE8, they likely didn't bother about :last-child
until post-IE8.
If you know you will only have four li
elements, then you should be able to use adjacent sibling selectors to reach the fourth li
:
.footerMenu li:first-child + li + li + li
The link you provided shows that it isn't supported for IE8... IE9+ only. Googling last-child IE8 brings up a whole host of similar queries.