This wiki has been archived and is now read-only.


From HTML Wiki
Jump to: navigation, search


The <pre> element represents a block of preformatted text.


  • Some examples of cases:
    • e-mail
    • computer code
    • ASCII art...
  • This element is used with the code element, the samp element, or the kbd element, and so on, according to the kind of content inside a pre element. [Example B]
  • The author should consider accessibility, when use the pre element. This is because, when speech synthesizers, braille displays, and the like is used, there is a possibility that preformatted text is destroyed. For exapmle, For cases like ASCII art, it is likely that an alternative presentation, such as a textual description, would be more universally accessible to the readers of the document.

HTML Attributes

See global attributes.


Example A

[try it]

Line 1.
           Line 2 is to the right of line 1.
           Line 3 aligns with line 2.

Example B

With the code element [try it]:

  function Panel(element, canClose, closeHandler) {
    this.element = element;
    this.canClose = canClose;
    this.closeHandler = function () { if (closeHandler) closeHandler() };

HTML Reference

The HTML5 specification defines the <pre> element in 4.5.3 The pre element.