Home  >  Article  >  Web Front-end  >  Summarize various methods of how to use spaces in html

Summarize various methods of how to use spaces in html

伊谢尔伦
伊谢尔伦Original
2017-06-01 16:29:325802browse

In the process of learning the basic code of html, I believe it will involve how to write the space code of html. We usually use spaces when editing programs. The character entity of the html space code is a non-breaking space  . This is the space code in html. Of course, there are space symbols, space characters, blank lines, etc. The following article will explain these contents related to spaces one by one.

1. You can first take a look at "HTML/CSS Quick Start" Introduction to spaces in the tutorial

1. Introduction to spaces in HTML character entities

Summarize various methods of how to use spaces in html

Multiple spaces in html will be shortened into one by the browser, so We need to use   to achieve the purpose of multiple spaces. nbsp is non-breaking space, which is different from ordinary spaces, that is, it does not break white spaces. That is to say,   is used in HTML code to generate a blank and prevent the browser from wrapping lines in this blank. For example, using   in two Summarize various methods of how to use spaces in html tags can prevent line wrapping caused by the image being too wide to exceed the width of the browser. That is to say, if you use normal spaces, when the browser width is not enough, the second img will be folded to the next line, and with  the two img will be displayed on the same line.

2. Sharing about space characters and space symbols in HTML

1. About the summary of space character entities in HTML Share

  Non-breaking space (non-breaking space) character encoding: In HTML, generated by pressing the space key, spaces do not accumulate (only count as 1) , you need to use html entity representation to be able to accumulate.

Full-width space (Em Space) character encoding: em is the unit of measurement for typography. It is equivalent to the currently specified point number. For example, 1em in a 16px font is 16px. This space has a very robust characteristic, and the width it occupies is exactly 1 Chinese width.

Half-width space (En Space) character encoding: en is the unit of measurement for typography. It is half the width of em. For example, 1en is 16px in a 16px font, which is nominally the width of the lowercase letter n. This space has a very robust characteristic, and the width it occupies is exactly 1/2 the Chinese width.

2. Introduction to the space symbol (nbsp; ensp; emsp;) in html and a detailed explanation of the method of Chinese alignment

Summarize various methods of how to use spaces in html

Character usage skills:

1) Character output in HTML uses with charCode value;
2) In JavaScript files, to prevent garbled escaping, \u is paired with charCode Value;
3) In the CSS file, such as the content attribute of the CSS pseudo-element, use \ directly with the charCode value.

3. Introduction and usage instructions of spaces in HTML

1. Detailed introduction on how to insert spaces in HTML

Summarize various methods of how to use spaces in html

Normally, we use the space bar to type multiple spaces, and When writing code, spaces typed by the space bar, Tab key and Enter key will be automatically ignored by HTML (Hypertext Markup Language). HTML treats such keys as whitespace characters and displays them as a single whitespace interval. Although CSS provides various styles of spacing and indentation, there are also tools in HTML that allow you to define spacing yourself.

2. HTML 6 types of spaces description

Non-line breaking spaces ( ) are the width of regular spaces and can run in all major browsers. Several other spaces ( ,  ,  , ‌, ‍) have different widths in different browsers.
 It is called No-Break Space. It is the most common and most used space. Most people may only be exposed to  . It is a space generated by pressing the space key. In HTML, if you use the space bar to generate this space, the spaces will not accumulate (only count as 1). It can only be accumulated using html entity representation. The width occupied by this space is obviously and strongly affected by the font.

3. A brief discussion on spaces and empty lines in HTML code

Method 1: We can use the pre-formatted tag

, whether it is a space or an empty line Applicable to all lines. 

Method 2: We can use the space entity character   to replace spaces, and the newline tag
to replace blank lines. Although this method can get the display effect we want, it is not the most friendly to search engines because   and
have no semantics in HTML. So it is recommended to use it as little as possible. Also note that   must be lowercase, and the semicolon at the end cannot be omitted.

Method three: (suitable for spaces) Use full-width spaces

Questions and answers about spaces in HTML

##1.

HTML document

tag, how to remove spaces within a paragraph.

2.

li How to remove the default space in front of it?

3. Why are the spaces entered in

html not displayed?

【Related recommendations】

1.

Summary of space symbols and space character entities in html

The above is the detailed content of Summarize various methods of how to use spaces in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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