HTML pre tag

What Is the HTML Preformatted Text Tag (<pre></pre>)?

When you write HTML code you have line break characters, carriage return characters tabs etc. But HTML does not count them and provide output as single line. Sometimes we want that whatever we write in HTML code it should appear exactly same in browser too. For doing the same you can use pre tag. The text appear exactly same in the browser as it is typed in HTML code or file. Spaces, tabs, and line breaks that present in your HTML code will remain same with the use of pre tag. Example


<pre>
		Roses are Red,
				Violets are blue,
			I may sound crazy,
		But I love you!
</pre>
Output

		Roses are Red,
				Violets are blue,
			I may sound crazy,
		But I love you!

FAQ 1. Can I change the font size and color of preformatted text? Yes, you can customize the appearance of preformatted text using CSS properties such as font-size, color, font-family, and background-color. 2. When should I use the HTML pre tag? Use the pre tag whenever you need to preserve spaces, tabs, and line breaks in text. It is especially useful for programming examples, poems, formatted output, and text-based diagrams.