Publish in HTML Tutorial el 25/05/2025 14:59
The <pre>
element in HTML defines preformatted text. Text within a <pre>
element is displayed exactly as written in the HTML source code - preserving both spaces and line breaks. This makes it ideal for displaying code blocks, ASCII art, or any content where whitespace matters.
<code>
element for code blocksHere's a simple example showing how the pre element preserves formatting:
While <pre>
preserves formatting, you can combine it with <code>
for better semantic meaning:
The <pre>
element is perfect for displaying ASCII art:
You can update the content of a <pre>
element dynamically with JavaScript:
Here's how you can use <pre>
to display console-like output:
<pre>
elements don't wrap text. Add white-space: pre-wrap;
in CSS to enable wrapping.role="code"
).tab-size
property.The <style> HTML element contains style information for a document, or part of a document. ...
The <strong> element is used to indicate that its content has strong importance, seriousnes...
The <span> element is an inline container used to mark up a part of a text or document. Unl...
The <source> element is used to specify multiple media resources for media elements like &l...
The <small> element is used to represent side-comments and small print, typically for discl...
HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...