views:

535

answers:

3

I'm having some trouble getting this layout to work correctly in IE. The problem is that when I have a bit of small-caps, underlined text, an image with vertical-align set to middle breaks up the underline. Lower case letters have their underline shifted down. See the picture.

This looks fine in Firefox, Chrome and Opera, but it's broken in every version of IE that I tried, including 8. This happens for underlined links as well. Here's the code:

<html>
<head>
 <title>Test</title>
 <style type="text/css">
  img { vertical-align: middle; }
  span { text-decoration: underline; font-variant: small-caps; }
 </style>
</head>
<body>
 <img src="pic.png">
 <span>Abc QWerty AbCdEfGhIjKlMnOpQrStUvWxYz1234567890</span>
</body>
</html>

Thanks for any suggestions.

+3  A: 

If you don't care about CSS validation adding a zoom:1 declaration (or any other hasLayout invoking declaration) to your span style will solve the problem (in IE6/7 at least).

Richard M
Thanks for this, it worked
@Richard: Hmm, can't see any effect of this. The underlines still have different distances to each letter...
Oliver Giesen
@Oliver: I've tested it again and the `zoom:1` solution works (for the test case in the question) for me in IE6. If you're having the problem on a more complex page you should ask a new question posting your code.
Richard M
@Richard: I'll have to retest. FWIW, in my case the text wasn't explicitly underlined like in the example but only implicitly because it was also a link (i.e. `<a href=...`)
Oliver Giesen
A: 

Both zoom:1 or float:left will also work...

Webdevelopertut

Webdevelopertut
A: 

I also haven't managed to get this to work (zoom:1 does nothing for me). I now resorted to using border-bottom instead of underline...

Oliver Giesen