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.
Html:

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.

w3cschool简介

w3cschool.cn注册并建站于2009年8月,是国内较早以w3c标准为教程材料的的技术在线教程类网站之一,后来经过原站长多年经营,成为广为人知的w3cschool在线教程网站,2016年开始公司化运作。


网站主要为初学者提供入门的学习内容和日常技术资料查询服务。


为了能更好的服务大家,本站中提供了大量的在线实例,通过实例,您可以更好地学习如何建站。


并且我们会根据当前互联网的变化实时更新内容。


对于我们网站及内容如有不足的地方,欢迎广大技术爱好者在本站留言提供意见、建议。




Try it out . . .