Christian Heilmann

Q&A: Extra whitespace in lists

Monday, February 12th, 2007 at 11:32 am

Q: I keep having problems with a list showing up as two lines of instead of one (there is a big gap between the items) in Internet Explorer 6. I don’t know what is causing it as there is nothing inside the list items but text.

A: The problem is that you most likely have line breaks and tabs in between the closing LI and the next opening LI. This is a great thing to do to keep your code readable but Internet Explorer 6 (MSIE6) has a problem with it. One workaround would be to add the linebreaks and tabs inside the brackets of the LI elements, but that is neither pretty nor clever as MSIE6 is on the decline. You can use CSS to work around the same problem by using a fixed height for MSIE6 and overriding this for newer and better browsers that understand the child selector. A sequence like li{height:1em;} html>body li{height:auto;} will fix your problem as MSIE6 also increases the size of the element when the font is larger or the content of the list item spills out into two lines. Without the second selector newer browsers would cut off your content.

This has been published in the Q&A session of the UK based paper magazine “net”. Reproduction rights were given by the publisher.

[tags]netmagazine,CSS,lineheight,whitespace,problem,IE,webdevtrick[/tags]

Share on Mastodon (needs instance)

Share on BlueSky

Newsletter

Check out the Dev Digest Newsletter I write every week for WeAreDevelopers. Latest issues:

Word is Doomed, Flawed LLM benchmarks, hard sorting and CSS mistakes Spot LLM benchmark flaws, learn why sorting is hard, how to run Doom in Word and how to say "no" like a manager.
30 years of JS, Browser AI, how attackers use GenAI, whistling code Learn how to use AI in your browser and not on the cloud, why AI makes different mistakes than humans and go and whistle up some code!
197: Dunning-Kruger steroids, state of cloud security, puppies>beer
196: AI killed devops, what now? LLM Political bias & AI security Learn how AI killed DevOps, create long tasks in JS, why 1 in 5 security breaches are AI generated code & play "The Scope Creep"
195: End of likes, JS Zoo and Tim Berners-Lee doesn't see AI vs Web Meta kills like buttons, Tim-Berners-Lee thinks AI won't kill the web, GitHub is ending toasts and the worst selling Microsoft product.

My other work: