Home Web Front-end HTML Tutorial How to wrap text in pre tag in html? Usage examples of html pre tag

How to wrap text in pre tag in html? Usage examples of html pre tag

Aug 28, 2018 pm 01:41 PM
html

This article mainly introduces examples of how to use the html pre tag, and also introduces the role of the HTML pre tag. It uses examples to prove to everyone that pre is indeed useful. Tags, in the early stages, it is much easier to use pre tags than other tags. Okay, now let us take a look at the following article

First let us understand what the pre tag in HTML can do?

What can the pre tag in HTML do? In layman’s terms, the pre tag can display all the text formats in it on the web page, such as spaces, line breaks, etc. It is displayed without leaving any trace by the browser. Let’s take a look at the effect.

First let us understand the role of the pre tag:

is the

 tag, which can correctly display the text format inside in the browser, just like the line break format, wrap the line inside (if you want to know more about HTML, please search " PHP Chinese website" to watch) <p><strong>The first one must be to understand how it wraps lines: </strong><br></p><p>For example, I create a new web page in the pre tag :</p><pre class='brush:php;toolbar:false;'><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP中文网</title>
</head>
<body>
<pre class="brush:php;toolbar:false">欢迎大家来到PHP中文网
Copy after login

This is a normal web page, as shown in the picture:

How to wrap text in pre tag in html? Usage examples of html pre tag

Now I wrap the above paragraph in it to display

<body>
<pre class="brush:php;toolbar:false">欢迎大家来到
PHP中文网
Copy after login

Now look at the effect:

How to wrap text in pre tag in html? Usage examples of html pre tag

You see, the above picture has completely changed one line, and all the spaces in the middle are displayed. In pre There is no need to add any tags to realize the line wrapping function

The second one is to take a look at the display of spaces

The space function of HTML pre tag is also the same as The lines are similar. If you enter three spaces in the text, then the three spaces will be displayed in the browser.

Let’s see the example:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP中文网</title>
</head>
<body>
<pre class="brush:php;toolbar:false">欢迎大 家来到PHP中文网(这里是一个空格)
Copy after login
欢迎大  家来到PHP中文网(这里是两个空格)
Copy after login
欢迎大   家来到PHP中文网(这里是三个空格)
Copy after login

这是一个普通的p标签,这里我用了 五个空格,你看到了没有

Let’s see the effect

How to wrap text in pre tag in html? Usage examples of html pre tag

This is the effect of the above space display. With comparison, we can easily find that the above space is also a space when displayed in the browser. Three spaces can It is displayed in the browser, but I used five spaces in the p tag, but when it comes to the browser, it becomes like not even one space.

This is the best use of the HTML pre tag for me. In any paragraph, you can enter any format you want by adding the

 tag, which is much more convenient. The meaning of the <strong><pre class="brush:php;toolbar:false"> tag in official terms is (preformatted text) pre-text format 
Copy after login
, which displays the text format in the browser (if you want to know more about HTML, please click :http://www.php.cnTo watch)

Okay, the above is an introduction to the role of HTML pre tags and examples of how to use spaces and how to wrap lines. . If you have anything you don’t understand, you can ask questions below.

【Editor's Recommendation】

How to write a relative path for the base tag in HTML? (Introduction to use included)

What is the usage of the src attribute of the HTML img tag? Analysis of specific usage methods (examples attached)

The above is the detailed content of How to wrap text in pre tag in html? Usage examples of html pre tag. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles