HTML Pre Tag

HTML Pre Tag

HTML Pre Tag

  • HTML pre tag is used to define Preformatted text which preserves both spaces and line breaks.

  • pre tag print the content on the web page as it is, written in the HTML file.

  • It is generally used to write computer code on HTML web page.

  • Generally, text written inside pre tags are in Courier font.


Example:
<pre>
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello, World!");
return 0;
}
</pre>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Pre Tag.

  • Whatever we write inside the pre tag is displayed as it is on the web page which preserves both line space and white space.

  • When we want to use multiple <br/> tags then the size of the code increases and to use the repeatedly same tag, again and again, which is not a good programming practice, So to avoid multiple <br/> tags we can use <pre> tag to get the same desired result.

  • In the same way, if we want to give more than one white space between the content then it is very handy, to use <pre> tag, to give more than one white space.

Run the code to see the effect.




HTML Pre Tag in Hindi

Best Use:360p or more (480p or 720p)
×

Course Menu