PRE tag.

Q2. Explain the use of <PRE> tag with the help of an example.

Ans. The <PRE> tag in HTML defines the preformatted text. This implies that this tag helps you not display text in the Web browser in a fixed-width font but also display the text in the same way as you have typed in it the code. The <PRE> tag displays the text in the Web browser with all blank lines and tabs.

The <PRE> tag is useful for displaying code in a Web page. The default text font that the PRE tag uses is the Courier font. You should use the <PRE> tag to maintain a text format, which includes line breaks and tabs.

Example of using the <PRE> tag:

<HTML>

<HEAD>

<TITLE> WELCOME TO HTML</TITLE>

</HEAD>

<BODY>

<PRE> This text is inside the PRE tag and therefore

and therefore

is displayed in a fixed-width

font, and it preserves

both spaces and

line breaks

</PRE> This text

is not inside the PRE tag

and therefore will be displayed

in a single line.

</BODY>

</HTML>

Leave a Reply

Your email address will not be published. Required fields are marked *

16 Views
%d bloggers like this: