You can apply the white-space property to any block-level element. In Netscape and Opera, it's possible to control spacing and line breaks inside paragraphs, header tags, and other elements using the white-space property.
Unfortunately, Explorer 5.x browsers (for Windows) ignore this extremely useful technique. Explorer 6 only supports it if you use a strict DOCTYPE definition. If you use a frameset or transitional DOCTYPE, the browsers ignore the property entirely.
Include the white-space property in your style definition like this:
white-space: pre; |
Use it with other style definitions to control whitespace and retain the same fonts and colors as the rest of the document. Here's a sample definition:
.preElement { white-space:pre; font-weight:bold; color:navy; font-family:arial; } |
When you apply this class to a page element, you get bold, navy text, in Arial. It retains line breaks and word spacing.