How to fix floated images and list overlap
The other day I was looking at my blog and saw that one of the posts had a left floated image followed by a bulleted list. The problem was that the list was not indenting properly the way it did when next to a paragraph without a floated element. After a bit of searching and hair pulling I found a discussion that solved my problem.
The problem illustrated
As you can see the list on the left image does not properly aligned, while the one on the right is. The fix is quite simple.
ul, ol { overflow: hidden; }
Use overflow:hidden on your ul and ol tags. This will stop your lists from flowing around images too, but that’s probably a good thing because a list flowing around an image isn’t very pleasing to the eyes.
Getting it to work in IE6
You didn’t think you were finished did you? When I did the redesign for ianhoar.com I really wasn’t sure if I would support Internet Explorer 6 at all, but in the end I decided that if I still have to support it on my professional projects then my blog should probably support this truly awful browser too.
The IE6 fix is a zoom:1 declaration. Unfortunately the zoom declaration is not valid CSS. You can get around this by creating a second CSS file called ie.css and use conditional comments when linking the file.
ul, ol { zoom:1; }
And the CSS conditional
<!--[if IE 6]> <link rel="stylesheet" href="ie.css" mce_href="ie.css" type="text/css" media="all" /> <![endif]-->
Your lists should look a lot nicer now when situated next to floated images or other floated elements.
Matth June 28, 2011 at 11:50 am
Wow, thanks for posting this tip. I’ve been struggling with this for years. This simple fix isn’t very well documented, so I appreciate that you took the time to mention it.
Rachel April 9, 2012 at 4:34 pm
Thank you! Such a simple fix for a really annoying problem.
csscoder April 16, 2012 at 1:22 pm
this is no good as it hides the bullets 🙁
Ian Hoar April 16, 2012 at 2:03 pm
I would have to see your issue to be able to know why.
Sam February 17, 2013 at 9:02 pm
Think WP should add this to their default style sheet. Seriously annoying.