The <pre> tag in HTML is used to define the block of preformatted text which preserves the text spaces, line breaks, tabs, and other formatting characters that are ignored by web browsers. Text in the <pre> element is displayed in a fixed-width font, but it can be changed using CSS. The <pre> tag requires a starting and end tag.
Note: The <pre>
 tag also supports the Event Attributes in HTML and Global Attributes in HTML.
<samp>
|
It defines sample output from a computer program
|
<var>
|
It defines a variable
|
<code>
|
It Defines a piece of computer code.
|
<kbd>
|
It defines keyboard input
|
Syntax:Â
<pre> Contents... </pre>
Example 1: These examples illustrate the <pre> tag in an HTML document.
HTML
< html >
< body >
< pre >
GeeksforGeeks
A Computer Science Portal For Geeks
</ pre >
</ body >
</ html >
|
Output:Â
Example 2:Â In this article we will see the implementation of pre tag with an example.
HTML
< html >
< head >
< title >pre tag with CSS</ title >
< style >
pre {
font-family: Arial;
color: #009900;
margin: 25px;
}
</ style >
</ head >
< body >
< pre >
GeeksforGeeks
A Computer Science Portal For Geeks
</ pre >
</ body >
</ html >
|
Output:Â
Supported Browsers:Â
- Google Chrome 1
- Edge 12
- Firefox 1
- Opera 15
- Safari 4
Last Updated :
05 Jan, 2024
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...