Providing you're just looking for a fallback solution for IE7, this can be done.
Add a new rule which start with *:first-child+html
and only IE7 will recognise it.
So in your case add
*:first-child+html #wrapper {
display: inline-block;
}
*:first-child+html #wrapper > .child {
display: inline-block;
}
Why *:first-child+html
? Well, that translates as an html element that is a following sibling of another element that is the first child of of their common parent. While it possible to create such DOMs in invalid application/xhtml+xml
-served XHTML and via JavaScript, in normal HTML the HTML parser rules mean that simply never happens.
But IE7 has a bug, where it matches the *:first-child
against the DOCTYPE node, which since that node is a preceding sibling node of the html element, the rule applies.
IE6 did not support :first-child
, IE8 and later do not match *
against the DOCTYPE node.
Adding *:first-child+html
to the same selector has the additional benefit of increasing the specificity of the selector, so it will always take precedence in IE7.
The additional rules are entirely valid CSS.
You can see it in action at http://alohci.net/static/ie7cssfallback.htm