I have some HTML that a 3rd party API builds, so I have no control of the output. The only thing I can change is the CSS. I would prefer not to use JavaScript, if possible.
What I’m trying to do is swap 2 elements using float:left on the second, so it’s displayed before the first one. This works well on modern browsers, but causes the “swapped” element to move to the second line on older IE browsers (specifically 6 and 7, and IE in compatibility mode).
HTML (cannot change)
<div class="wrapper">
<a class="page">Page: </a>
<a class="previous">Prev</a>
<span>
<a>1</a>
<a>2</a>
</span>
<a class="next">Next</a>
</div>
CSS
.wrapper{
line-height:36px;
}
.wrapper span, .page{
float:left;
}
.wrapper span a, .page{
display:inline-block;
}
.wrapper span a{
width:20px;
}
.previous, .next{
width:30px;
display:inline-block;
}
Modern Browser Screenshot

Internet Explorer Screenshot

The issue turned out to be a bug with how IE6 and IE7 (not present in IE8) handle
float:right;within a left-aligned element. Instead of simply positioning the element on the closest point to the left, past any content (as modern browsers do), IE6 and IE7 position the element in the farthest right point possible (which, isn’t that much different in terms of definition, but makes a huge difference in cases like this).Anyway, to get past this limitation,
float:right;could not be used as a solution. As there was no way of knowing (without JavaScript, which the OP stated should not be used) what the width of.content spanwas (variable number of pages), a static width could not be used on.wrapper. Instead, the “Next” and “Prev” link elements had to be “discarded” until the end, then positioned absolutely (relative to.wrapper) after thewidthof.wrapperhad been figured out.jsFiddle Example
The Magical CSS