How to insert spaces/tabs in text using HTML/CSS

后端 未结 18 2580
死守一世寂寞
死守一世寂寞 2020-11-28 01:20

Possible ways:

 ... 

or

style=\"white-space:pre\"

Anything else?

相关标签:
18条回答
  • 2020-11-28 02:04

    <span style="padding-left:68px;"></span>

    You can also use:

    padding-left
    padding-right
    padding-top
    padding-bottom
    
    0 讨论(0)
  • 2020-11-28 02:06

    You can do through padding like <span style="padding-left: 20px;">, you can check more ways here at - blank space in html

    0 讨论(0)
  • 2020-11-28 02:09

    You can use &nbsp; for spaces, &lt; for < (less than, entity number &#60;) and &gt; for > (greater than, entity number &#62;).

    A complete list can be found at HTML Entities.

    0 讨论(0)
  • 2020-11-28 02:11

    Alternatively referred to as a fixed space or hard space, non-breaking space (NBSP) is used in programming and word processing to create a space in a line that cannot be broken by word wrap.

    With HTML, &nbsp; allows you to create multiple spaces that are visible on a web page and not only in the source code.

    0 讨论(0)
  • 2020-11-28 02:11

    Use the standard CSS tab-size.

    To insert a tab symbol (if standard tab key, move cursor) press Alt + 0 + 0 + 9

    .element {
        -moz-tab-size: 4;
        tab-size: 4;
    }
    

    My preferred:

    *{-moz-tab-size: 1; tab-size: 1;}
    

    Look at snippet or quick found example at tab-size.

    .t1{
        -moz-tab-size: 1;
        tab-size: 1;
    }
    .t2{
        -moz-tab-size: 2;
        tab-size: 2;
    }
    .t4{
        -moz-tab-size: 4;
        tab-size: 4;
    }
    pre {border: 1px dotted;}
    <h3>tab = {default} space</h3>
    <pre>
    	one tab text
    		two tab text
    </pre>
    
    <h3>tab = 1 space</h3>
    <pre class="t1">
    	one tab text
    		two tab text
    </pre>
    
    <h3>tab = 2 space</h3>
    <pre class="t2">
    	one tab text
    		two tab text
    </pre>
    
    <h3>tab = 4 space</h3>
    <pre class="t4">
    	one tab text
    		two tab text
    </pre>

    0 讨论(0)
  • 2020-11-28 02:11

    You can use this code &#8287; to add a space in the HTML content. For tab space, use it 5 times or more.

    Check an example here: https://www.w3schools.com/charsets/tryit.asp?deci=8287&ent=ThickSpace

    0 讨论(0)
提交回复
热议问题