How to type spaces in HTML

May 03, 2021 12:29 HTML

Table of contents

How to type spaces in HTML

  • Type a space

    In the html web page a space, we can type the "space" key to achieve.

  • Multiple html space characters

    If you want to achieve multiple space gaps in html, if you type more than one Space key, you end up showing only one space gap. T his is when we need real space character   It's gone.

Code example:

学编程上w3cschool 学编程上w3cschool  学编程上w3cschool 

Try it out . . .

How to type spaces in HTML

Multiple escape characters for HTML spaces

  • Normal English half-corner spaces
  • No-break space (normal English half-corner space but no line break)
  • The Chinese full-width space (one Chinese width)
  • en space (half Chinese width)
  • em space (one Chinese width)
  • - Quarter em space (quarter Chinese width)

nbsp has an uninterrupted (non-breaking) feature compared to the usual space ( ). T hat is, continuous nbsp is displayed on the same line. Even with 100 consecutive nbsp, browsers don't split them into two rows.

How to dynamically add spaces to HTML with JS

Front-end projects sometimes need to dynamically add spaces with JS, for example to take care of the style of CSS or to take care of the implementation of special effects. J ust use this method.

If you don't just want to null between div, but you want to add spaces dynamically, so (jquery)

$("#id").innerHTML += " ";

Use HTML (hyper-text markup language) to add paragraph spacing
If you want the text you enter to form a paragraph, insert a paragraph before the paragraph, and insert a paragraph between the sentence and the sentence to split the sentence.







Try it out . . .