View video tutorial

HTML <pre> Tag

HTML

The <pre> tag is used to display pre-formatted text.

HTML <pre> Tag


The <pre> element represents the preformatted text where the text preserves both space and line breaks and the text will appear as written in the source code.

To display special characters inside <pre> element, the characters have to escape using their respective HTML entities.

Global attributes

Global attributes may be applied on all elements, although some elements may have no effect on them.

<accesskey>, <class>, <contenteditable>, <contextmenu>, <data-*>, <dir>, <draggable>, <dropzone>, <hidden>, <id>, <lang>, <spellcheck>, <style>, <tabindex>, <title>, <translate>.

Learning with HTML Editor "Try it Now"

You can edit the HTML code and view the result using online editor.

Example

<pre>
    The pre element represents
       the preformatted text where the text 
         preserves both space and line breaks 
              and the text will 
    appear as written 
         in the source code.
</pre>
Try it Now »

Click on the "Try it Now" button to see how it works.