search
HomeWeb Front-endHTML TutorialSummarize various methods of how to use spaces in html

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. <p>Method 2: We can use the space entity character   to replace spaces, and the newline tag <br> 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 <br> 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. </p><p>Method three: (suitable for spaces) Use full-width spaces</p><p><span style="color: rgb(255, 0, 0); font-size: 16px;"><strong>Questions and answers about spaces in HTML</strong></span></p>##1. <p>HTML document </p><p> tag, how to remove spaces within a paragraph. <a href="http://www.php.cn/wenda/71975.html" target="_self"></a></p>2. <p>li How to remove the default space in front of it? <a href="http://www.php.cn/wenda/70826.html" target="_self"></a></p>3. Why are the spaces entered in <p>html not displayed? <a href="http://www.php.cn/wenda/2785.html" target="_self"></a></p>【Related recommendations】<p></p>1. <p>Summary of space symbols and space character entities in html<a href="http://www.php.cn/div-tutorial-363813.html" target="_self"></a></p>

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
HTML超文本标记语言--超在那里?(文档分析)HTML超文本标记语言--超在那里?(文档分析)Aug 02, 2022 pm 06:04 PM

本篇文章带大家了解一下HTML(超文本标记语言),介绍一下HTML的本质,HTML文档的结构、HTML文档的基本标签和图像标签、列表、表格标签、媒体元素、表单,希望对大家有所帮助!

html和css算编程语言吗html和css算编程语言吗Sep 21, 2022 pm 04:09 PM

不算。html是一种用来告知浏览器如何组织页面的标记语言,而CSS是一种用来表现HTML或XML等文件样式的样式设计语言;html和css不具备很强的逻辑性和流程控制功能,缺乏灵活性,且html和css不能按照人类的设计对一件工作进行重复的循环,直至得到让人类满意的答案。

web前端笔试题库之HTML篇web前端笔试题库之HTML篇Apr 21, 2022 am 11:56 AM

总结了一些web前端面试(笔试)题分享给大家,本篇文章就先给大家分享HTML部分的笔试题(附答案),大家可以自己做做,看看能答对几个!

总结HTML中a标签的使用方法及跳转方式总结HTML中a标签的使用方法及跳转方式Aug 05, 2022 am 09:18 AM

本文给大家总结介绍a标签使用方法和跳转方式,希望对大家有所帮助!

HTML5中画布标签是什么HTML5中画布标签是什么May 18, 2022 pm 04:55 PM

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

html中document是什么html中document是什么Jun 17, 2022 pm 04:18 PM

在html中,document是文档对象的意思,代表浏览器窗口的文档;document对象是window对象的子对象,所以可通过“window.document”属性对其进行访问,每个载入浏览器的HTML文档都会成为Document对象。

html5废弃了哪个列表标签html5废弃了哪个列表标签Jun 01, 2022 pm 06:32 PM

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

Html5怎么取消td边框Html5怎么取消td边框May 18, 2022 pm 06:57 PM

3种取消方法:1、给td元素添加“border:none”无边框样式即可,语法“td{border:none}”。2、给td元素添加“border:0”样式,语法“td{border:0;}”,将td边框的宽度设置为0即可。3、给td元素添加“border:transparent”样式,语法“td{border:transparent;}”,将td边框的颜色设置为透明即可。

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Atom editor mac version download

Atom editor mac version download

The most popular open source editor