<preformat> Preformatted Text

Text in which spaces, tabs, and line feeds must be preserved. Content is typically displayed in monofont to preserve character alignment.


The <preformat> element is typically used for machine-related communication such as ASCII art and error message reports, in which whitespace such as tabs, line feeds, and spaces should be preserved.
The @position attribute may be used to indicate whether this element must be anchored at its exact location within the text, or whether it may float (for example, to the top of the next page, into the next column, to the end of a logical file, or within a separate window). For the typical <preformat> element, the “float or anchor” decision will be governed by the size of the object. For example, short preformat fragments are typically anchored whereas longer preformats are typically placed elsewhere such as in a separate window or at the end of the document.
The MathML elements to describe equations are not permitted within <preformat>. If equations are encountered within computer code, they can be tagged using the element <named-content> to preserve the fact that they were equations or the element <styled-content> to preserve that fact that they were set in a math font.
Related Elements
Best Practice: Although it is possible to use <preformat> to tag any format-preserving object, some of these objects have semantic elements that should be used in preference. For example:
  • Poetry and verse should usually be tagged with the <verse-group> element, which may not preserve the exact indentation, but is more likely to be displayed in a proportional font.
  • Programming code, scripts, pseudo-code, DTDs and Schemas, and XML instances should be tagged with the <code> element, making full use of its attributes to identify the type of code.
  • Equations and math are typically tagged with <disp-formula> or <inline-formula>.
orientation (default = portrait)
position (default = float)

Base Attributes

Miscellaneous non-JATS-specific Attributes

xml:space (fixed value = preserve)
Models and Context
May be contained in
Any combination of:
Content Model
<!ELEMENT  preformat    %preformat-model;                            >
Expanded Content Model

(#PCDATA | alt-text | long-desc | email | ext-link | uri | inline-supplementary-material | related-article | related-object | hr | bold | fixed-case | italic | monospace | overline | overline-start | overline-end | roman | sans-serif | sc | strike | underline | underline-start | underline-end | ruby | alternatives | inline-graphic | inline-media | private-char | chem-struct | inline-formula | tex-math | mml:math | abbrev | index-term | index-term-range-end | milestone-end | milestone-start | named-content | styled-content | fn | target | xref | sub | sup | x | attrib | permissions)*

Tagged Samples
Error message
<preformat preformat-type="dialog" xml:space="preserve"
 C:\users\lap make
   'make' is not recognized as:
     - an internal or external command
     - an operable program
     - a batch file
<preformat preformat-type="poem">


 balloonMan  whistles
<preformat preformat-type="transcription">
 00 A: so, my [opinion is that]    
 00 B:        [you're not letting [me       
 00 C:                            [but 
    A: first of all   ] 
    B: finish] speaking] 
    C: really     ] 
 00 A:                that is not true at all
Related Resources