- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML Tag
The <pre> tag in HTML is used to set preformatted text. The text in it preserves spaces and line breaks i.e. the text appears the same in the web page as it is added under the HTML code.
Let us now see an example to implement the <pre> tag −
Example
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <pre> This is a demo text and will appear in the same format as it is visible here. The pre tag displays the text in a fixed-width font. It preserves both spaces and line breaks as you can see here. </pre> </body> </html>
Output
In the above example, we have set some text which has some unexpected space and line breaks. This is done just to show the usage of <pre> to display the text as it is −
<pre> This is a demo text and will appear in the same format as it is visible here. The pre tag displays the text in a fixed-width font. It preserves both spaces and line breaks as you can see here. </pre>
Now, since we have used the <pre> tag, the above text will get displayed as it is on the web page by preserving the space and line breaks.
Advertisements