views:

85

answers:

3

This is the HTML:

<h2>
  Log in
  <a onclick="doSomething()" href="#" class="float-right">&nbsp;</a>
</h2>

This is the CSS:

.float-right {
    float: right;
    background: url(img.png);
    width: 10px;
    height: 10px;
    text-decoration: none;
}

So this should make the .float-right element float to the right of the text in the header, but in IE7 it doesn't! I don't care about IE6, I just have to get this working in IE7 and newer.

+2  A: 

try adding display:block; to the css

rikh
Yes, thats what is missing, also see my other comment.
Zoidberg
I thought `display: block` is implied on floated elements...and it still doesn't work when I add that rule.
Deniz Dogan
+1  A: 

Have you tried to move the code around?

<h2>
  <a onclick="doSomething()" href="#" class="float-right">&nbsp;</a>
  Log in
</h2>
Samuel
This actually works... But why!?
Deniz Dogan
I think it's because h2 by default is a block, which takes up 100% width. IE calculates it's width before seeing the floated element. but this is just a guess.
Samuel
A: 

Is there a sample online we could see?

Matt Turner
Sorry, there is not.
Deniz Dogan