Home HTML Pre Element Keep Formatting with the Pre Element
Search MS Office A-Z | Search Web Pages/ Design A-Z
Keep Formatting with the Pre Element
Sometimes you dont want to trust the browser to render spacing, tabs, and returns on its own. Poetry, formulas, or programming code, for example, may have their meaning changed or be harder to read if the browser is allowed to do its own thing.
But theres an easy workaround you can use: the <PRE> element. The text between <PRE> and </PRE> is preserved in its original state and wont reflow the text when the browser window is resized. The code for this element looks like this:
<PRE>
This text breaks
like a poem would
yet is not, in fact,
a poem, as far
as I can tell.
</PRE>
However, you cant retain everything from the original text. Browsers render preformatted text in a monospaced font, resembling Courier, and retain only simple formatting, such as bold and italics.
Get Specialized
These special treatments of text are essential parts of any Web authors knowledgebase. Keep them on hand when you need to create quotes, let others know when you have inserted text, or maintain the original formatting for a block of text.