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

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

Possible ways:

 ... 

or

style=\"white-space:pre\"

Anything else?

相关标签:
18条回答
  • 2020-11-28 01:55

    Here is a "Tab" text (copy and paste): " "

    It may appear different or not a full tab because of the answer limitations of this site.

    0 讨论(0)
  • 2020-11-28 01:58

    If you're asking for tabs to align stuff in some lines, you can use <table>.

    Putting each line in <tr> ... </tr>. And each element inside that line in <td> ... </td>. And of course you can always control the padding of each table cell to adjust the space between them.

    This will make them aligned and they will look pretty nice :)

    0 讨论(0)
  • 2020-11-28 01:58

    White space? Couldn't you just use padding? That is an idea. That is how you can add some "blank area" around your element. So you can use the following CSS tags:

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

    Types of Spaces in HTML

    Creates four spaces between the text- &emsp;

    Creates two spaces between the text - &ensp;

    Creates a regular space between the text - &nbsp;

    creates a narrow space ( similar to regular space but slight difference - "&thinsp";

    spacing between sentences - "</br>"

    This link might help you. Check out [https://hea-www.harvard.edu/~fine/Tech/html-sentences.html]

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

    user8657661's answer is closest to my needs (of lining things up across several lines). However, I couldn't get the example code to work as provided, but I needed to change it as follows:

    <html>
        <head>
            <style>
                .tab9 {position:absolute;left:150px; }
            </style>
        </head>
    
        <body>
            Dog Food: <span class="tab9"> $30</span><br/>
            Milk of Magnesia:<span class="tab9"> $30</span><br/>
            Pizza Kit:<span class="tab9"> $5</span><br/>
            Mt Dew <span class="tab9"> $1.75</span><br/>
        </body>
    </html>
    

    If you need right-aligned numbers you can change left:150px to right:150px, but you'll need to alter the number based on the width of the screen (as written the numbers would be 150 pixels from the right edge of the screen).

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

    To insert tab space between two words/sentences I usually use

    &emsp; and &ensp;

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