Space in HTML displays distance problem

Source: Internet
Author: User

One, use full-width space

Full-width spaces are interpreted as Chinese characters, so they are not interpreted as HTML separators and can be displayed in the actual number of spaces.

Second, the use of space substitution symbol

Alternate symbols include alternate symbols where spaces are needed, which are interpreted by the browser as spaces.

There are several alternative symbols for spaces:

name numbering Description
  & #160; Continuous white space (1 character width)
  & #8194; Half Blank (1 character width)
  & #8195; A blank (2 character width)
  & #8201; Narrow white space (less than 1 characters wide)

You can use a name or number as a substitute for a space, the name must be lowercase, and the end ";" cannot be omitted.

such as: Huan    ying    light    Pro!

The display effect is: Welcome!

Note that if there are English words in the text, the blanks are added between the letters, not between the words.

Third, using the CSS Text-indent property

The Text-indent property of the CSS is used to set the first line indent, which can be a length value with a unit, and the browser sets the specified length of space at the beginning of the first line of the paragraph. Like what:

<div style= "Text-indent:2em" > Welcome! </div>

Description: EM is a relative length unit, and 2EM represents the distance to indent two characters.

Four, the space in the HTML phenomenon

    <style type= "Text/css" >        {            border: 1px solid red;             font-family:"song body";            /* font-family:arial; */            /* font-family: "SimSun"; */            /* font-family: ' Microsoft yahei '; */             font-size: 20px;        }     </style>
    <spanclass= "Blankone">  </span>    <spanclass= "Blankone">&nbsp;</span>    <spanclass= "Blankone"style= "margin-left:10px;">Song</span>

Five. contenteditable= ' true ' div edit whitespace phenomenon

    <styletype= "Text/css">. Blankone{Border:1px solid Red;font-family:"The song Body";font-size:20px;        }    </style>    <!--contenteditable=true The white space width of the contents of the Cocoa Editor Firefox: All half Chinese characters width Google Chrome: The first space is the second space is half a Chinese character IE browser: Half a space -    <Divclass= "Blankone"contenteditable= "true"></Div>    

Space in HTML displays distance problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.