HTML pre tag
The HTML <pre> tag is used to specify pre formatted texts. Texts within <pre>.......</pre> tag is displayed in a fixed-width font. Usually it is displayed in Courier font. It maintains both space and line break.
It is widely used to display language examples e.g. Java, C#, C, C++ etc because it displays the code as it is typed.
<pre>
This is a formatted text
by using the HTML pre tag. It maintains
both space and line break.
</pre>
Output
This is a formatted text by using the HTML pre tag. It maintains both space and line break.
<pre>
package com.easytolearning;
public class MyJava{
public static void main(String args[]){
System.out.println("hello java");
}
}
</pre>
Output
package com.easytolearning;
public class MyJava{
public static void main(String args[]){
System.out.println("hello java");
}
}
Attribute | Value | Description |
---|---|---|
width | number | Not supported in HTML5. Specifies the maximum number of characters per line |
© 2025 Easy To Learning. All Rights Reserved | Design by Easy To Learning