Monospace font in IE8 ignores spaces

white-space: pre-wrap
react white-space: nowrap
html white space
textarea whitespace
white-space word-break
pre line wrap
mdn whitespace pre
mozilla white space

I'm trying to get a monospaced asci table working, as seen here: <pre> tag and css font-family

This works for me on all browsers, except IE8.

On IE8, the spaces all get compressed into one space. (so the columns disappear)

Any ideas on why IE8 is doing this?

Thanks in advance,


Add white-space:pre to your element to preserve white-space characters.

Fixing browsers' broken monospace font handling, of monospace fonts in a range of situations, but an unusual CSS rule can fix this problem. Line 7 restores the normal text size in Internet Explorer and Opera. On Firefox and IE (IE is a .eot file, converted from the .ttf), I have character width problems for &nbsp and &#32. Using the pre-defined monospace font, &nbsp displays in the proper width. But if I use Ubuntu Mono or my own monospace truetype font, the space character is too narrow, and the text does not vertically align across line breaks.

HTML default behaviour is to compress multiple white spaces down to a single space, unless explicitly told not to.

The way to tell it not to do this is to use the CSS white-space property. The value you're probably looking for is to set it to white-space:pre;, which will set a element to display all white space without compressing it.

You can of course also use the <pre> tag itself, which has white-space:pre; set by default. Note that this can be overridden in your stylesheets, so if a <pre> tag isn't working, this is probably the reason. (if this is happening, you can use the Developer Tools window to examine the styles being applied to the element)

In addition to white-space:pre;, there are a couple of other values of the white-space property which you can also use, depending on your requirements: pre-wrap and pre-line.

You can find out more about the differences between them, with examples, here:

Hope that helps.

fontFamily property (Windows), CSS 2.1, Section 5.2.2 If the font family name contains white space, it should appear in single or double quotation The default for this property can be set for Windows Internet Explorer on the General tab of the sans-serif; } .monospace { font-family: Courier, Monaco, monospace; } .cursive { font-family:� Line 7 restores the normal text size in Internet Explorer and Opera. Situations where browsers reduce the text size. All of the major browsers reduce the text size for HTML elements that default to a monospace typeface: pre (preformatted text), code (programming code), kbd (keyboard input), samp (sample output), and tt (typetype text).

I have tried this and it worked... (perhaps it helps) Then, fix the rest with styles.

<svg width="600" height="150" font-family="monospace"  xml:space="preserve">
<style type="text/css">
.font{text-anchor: start; font-size: 12px;font-weight: normal; font-family: "DejaVu Sans Mono", sans-serif;white-space: pre-wrap;}

IE : 'ch' unit inconsistencies., I'm struggling with the 'ch' unit in Internet Explorer. IE doesn't include the spacing around the character in the calculation. There is a difference – monospace fonts (of which braille fonts are a subset) all have the quality� ** If the image does not show, use this link or see the attachment. Consolas can be download from microsoft. The problem is: Consolas would not be displayed as a monospace font in MS Word while entering two or more continuous white spaces.

Remove Whitespace Between Inline-Block Elements, I remember being a young developer during the Internet Explorer 6 The best white-space solution is to set a font-size of 0 on the parent to the� The latter allows selection of only monospaced fonts. As a user I expected that whenever text was displayed in monospace it would use the font as configured. It is surprising and annoying to me as a web author that I cannot tell IE to use the monospace font which the user has chosen. – Lawrence Dol Feb 5 '13 at 21:35

<tt>: The Teletype Text element (obsolete), User-configured changes to the default monospace font setting may take precedence over your CSS. Although this element wasn't officially� The only monospaced TrueType fonts shipped by Microsoft are Courier New, which shipped with Windows 3.1, and Lucida Sans Typewriter, which was included in the TrueType Font Pack. All other TrueType fonts included with Windows 3.1 and the TrueType Font Pack are proportional fonts.

white-space, The white-space CSS property sets how white space inside an element is handled. I am trying to output some html in monospaced font, and I want spaces to take up the same width as any other character. i thought this would be easy for monospaced fonts - surely &ensp; and &emsp; would both be the same width? Some things are meaningless in monospaced fonts. Think of all the characters that have "zero-width" in their names.