How to stop Browser from replacing multiple space by single space?

后端 未结 5 1651
迷失自我
迷失自我 2020-12-11 16:00

Browser is replacing Multiple space between words to the single space in html page. for e.g if my text is \'AB-DC 3\' in Browser its showing \'AB-DC 3\'<

5条回答
  •  無奈伤痛
    2020-12-11 16:00

    On the Op scenario:
    Use white-space:pre; (no wrap except at
    ) or white-space:pre-wrap; (wrap when needed).

    Example:

    body{
      margin: 0;  
    }
    
    div {
      width: 200px;
      height: 100px;
    }
    
    #a {
      white-space:pre;
      background: gold;
    }
    
    #b {
      white-space:pre-wrap;
      background: skyblue;
    }
    This is some Text writen on here as example.
    Here's a second sentence after the line-break .
    This is some Text writen on here as example.
    Here's a second sentence after the line-break .

    Single White spaces:
    Sometimes you need to use single spaces, like at the start of a sentence (when it is ignored). In situations like this, the best choice is to use   instead.

    Example:

    p:nth-of-type(1) {
      font-size: 2em;
      background: tomato;  
    }
    
    p:nth-of-type(2) {
      font-size: 2em;
      background: greenyellow;  
    }

    content

     content

提交回复
热议问题