views:

77

answers:

4

I am attempting to float a span to the right within an h2 element. In IE8 and Firefox this works fine; in IE7 it is not floating.

The HTML:

<h2>
    <span id="spanA"> /*Should be floated to the right*/
    <span id="spanB">
    <span id="spanC">
</h2>

The CSS:

#spanA{
    float: right;
}

Any ideas as to what could be wrong?

+1  A: 

Maybe are you experiencing this Ie7 floating bug?

thesp0nge
There is no height set for the containing element, so it isn't this bug. Thanks though!
dmr
+4  A: 

The span tag is an inline element not a block level element. Thus it doesn't float when rendered according to specification. Have you tried adding display:block; to the css for #spanA ?

imightbeinatree at Cloudspace
Doesn't help :(
dmr
i made a test page for you with a full code sample, i tested it in IE7 using the IETester tool (http://www.my-debugbar.com/wiki/IETester/HomePage) that allows you to open up and view a page as it would look in multiple versions of IE and it seems to work right in IE7. What specific version of IE7 are you using?My test page: http://www.cloudspace.com/test/float-test.html
imightbeinatree at Cloudspace
+2  A: 
<h2>
    <span id="spanA"> /*Should be floated to the right*/
    <span id="spanB">
    <span id="spanC">
</h2>

add this css:

h2 #spanA
{
float:right;
clear:right;    
}
Prashant
Adding clear: right; doesn't seem to help. Just curious- why did you think it would help?
dmr
A: 

so use position:absilute and right:0;

this is last soluction i hope not in other opction..

Prashant