Get the App
SLTechnology News&Howtos  ›  Development  › 

How to insert spaces in HTML

Shulou Source: shulou.com Published: 2022-06-01 10:18:44 09月24日 Update

This article introduces the knowledge of "how to insert spaces in HTML". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Type in a space

In the html page, we can insert spaces by typing the "space" key.

Example: type one space in p.p1 and five spaces in p.p2. Note: this is a half-corner state. Type "space".

one

two

Test text | php Chinese website!

Test text | php Chinese website!

Effect picture:

As you can see, whether we type 1 or 5 spaces in HTML, or multiple other spaces, the Web browser automatically collapses these spaces to a single space.

So how do we display multiple typed spaces? You can type the "space" key in full-width state, for example:

one

two

Test text | php Chinese website!

Test text | php Chinese website!

Effect picture:

Description: full-width spaces will be interpreted as Chinese characters, displayed in the form of blank Chinese characters, and real numbers will be displayed (as many as there are).

Or use tags to solve this problem (type "space" in half-width state), for example:

one

two

three

four

five

six

Test text | php Chinese website!

Test text | php Chinese website!

Effect picture:

Use the space character of html

We can use the character entities that represent spaces in html to insert spaces in html pages. Let's take a look at the character entities that represent spaces in html:

Character: a blank space in continuous lines, the width of which is affected by the font.

  character: type half a "space" key (the width of half a Chinese character) in a full-width state.

  character: type the "space" key (the width of 1 Chinese character) in the equivalent full-width state.

Let's see the effect:

one

two

three

Test text | character nbsp displays spaces!

Tags: Space character text test Chinese net Chinese effect status width effect full width full width Chinese character middle table content half width can be passed multiple font entity more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MySQL Xiaomi Docker Shulou Tech Info