Browser white space rendering

后端 未结 3 1903
无人及你
无人及你 2020-12-07 01:06

Recently I was editing someone else\'s code and I noticed that spaces were used something like the following:

Some text     &
3条回答
  •  北海茫月
    2020-12-07 01:26

    As far as I know the rule is simple: more than 1 white-space each after another is always rendered as 1 white-space. If you want to render more, you need to use   entity.

    So if you have code ([whitespace] is here standard whitespace)

    [whitespace][whitespace]
    

    browser renders only one whitespace

    but when you have

    [whitespace] [whitespace]
    

    browser will render 3 white-spaces because normal white-spaces are separated by extra  

    This rule doesn't apply to entity version so if you have

      
    

    2 white-spaces will be generated

提交回复
热议问题