Nov
9

Paragraph width collapsing in Internet Explorer

By Sam  //  IE Problems  //  No Comments

This is one that I struggled with for quite a while.

In most (good) browsers when you don’t specify a width for an element (p, span, a, etc.) it will grow to be as wide as its content.

Not so in IE. In Internet Explorer your paragraph with an unspecified width could end up looking like this:

Hello
this is
my test
paragraph

So far the only solution that I’ve found seems to be to play with the whitespace attributes. In IE7 using white-space:pre; will make your elements behave as they should. In IE 6 only white-space:nowrap; will fix it – obviously meaning that your text is all going to be on a single line (not good).

If anyone has a better solution I would be glad to hear it…

Leave a comment

Sponsored links