<pre>
pre tag
The <pre>
tag in HTML is used to present text exactly as written, ensuring that spaces and line breaks remain unchanged.
Syntax
<pre>
Preformatted text here.
Line breaks and spaces are preserved.
</pre>
pre
Demo
Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and line breaks
<h1>The pre element</h1>
<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks
</pre>
Definition and Usage
The <pre>
tag is designed to display preformatted text, ensuring that spacing and line breaks remain as they appear in the source code.
You may also find these related tags useful:
Tag | Description |
---|---|
<code> | Displays a section of code. |
<samp> | Represents output from a program. |
<kbd> | Indicates keyboard input. |
<var> | Represents a variable. |
Conclusion
The <pre>
tag is an essential HTML element for displaying preformatted text, preserving all spaces, tabs, and line breaks. It ensures that text appears exactly as written in the source code, making it useful for code snippets, command-line outputs, and structured text. When combined with elements like <code>
, <samp>
, and <kbd>
, it provides better control over text formatting for technical and structured content.
<plaintext>
The <plaintext> element in HTML is used to display text exactly as it is, ignoring any HTML tags and rendering them as plain text.
<q>
The <q> element in HTML is used for inline quotations, usually rendered with quotation marks, to indicate a brief citation or excerpt within the surrounding text.