English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Inserting multiple spaces in a web page is a common practice in HTML, and there are many ways to achieve HTML spaces. Below, we will introduce them one by one.
: One-character half-width non-breaking space. If you need to insert multiple spaces in a web page, you can write the “ ” code repeatedly (Common Methods);
: One-character half-width space, or you can write “ ” repeatedly to insert multiple spaces;
: Two-character full-width spaces, or you can write “ ” repeatedly to insert more spaces;
: A space less than one character; Note: Remember to include the semicolon after the word, as it cannot be omitted and it is also part of the HTML code.
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8" /> <title>How to insert multiple spaces in a web page-Basic Tutorial(oldtoolbag.com)</title></head> body> <p>html space space basic tutorial (oldtoolbag.com)</p> <p>html space space basic tutorial (oldtoolbag.com)</p> <p>html space space basic tutorial (oldtoolbag.com)</p> <p>html space space basic tutorial (oldtoolbag.com)</p> </body> </html>Test to see ‹/›
The effect after running is as follows:
Why do we use html space symbol codes? Why not just type a few spaces on the keyboard? When you actually operate, you will find: by default, no matter how many spaces you type in the html source code, only one space is displayed in the browser. So we need to use html space symbol codes to achieve the effect of multiple spaces on the web page.
Why do we say it in the default case? In fact, we can also use the 'white-the 'space' attribute to achieve the effect of multiple spaces. It is to take 'white-the 'space' attribute value is set to 'pre', after setting it, the browser will keep the spaces and line breaks in the html source code. Now, when you type several spaces in the source code, the browser will display several spaces when running.
Note: Generally, in web development, the html space symbol code is used to achieve the effect of multiple spaces.
symbol | represents |
---|---|
Normal English half-width space | |
Normal English half-width space but does not wrap | |
Chinese full-width space (one Chinese width) | |
Half-width (en) space (half Chinese width, unaffected by font) | |
Full-width (em) space (one Chinese width, unaffected by font) | |
One quarter full-width (em) space (one quarter Chinese width) | |
Normal space | |
Compared to the normal space, the non-breaking space, the space generated by pressing the space key, does not accumulate |
em is a unit of typography, equivalent to the current specified point size. For example,1 em in16px font is16px.
em is a unit of typography, half the width of an em. According to definition, it is equivalent to half the font size (such as16px font is8). It is equal to the width of the lowercase letter n.
have a continuous (non-The (breaking) feature refers to:
Continuous nbsp will be displayed on the same line. That is, even if there are countless continuous nbsp, the browser will not split them into two lines.