Lokanath Nayak
Lokanath Nayak

Reputation: 87

How to add mult space text in a cell of a table

I have created a table and want to add a multi space text to it. Ex: HELLO<1stSPACE><2ndSPACE>WORLD. If i add as HELLO WORLD, then its printing with single space.

Any help?

<th width="6%" class="textLeft width100px borderTopNone" style="vertical-align:top;font-size:14px; white-space: nowrap;" colspan="2">HELLO  WORLD</th>

Thanks

Upvotes: 1

Views: 81

Answers (4)

Shirin Abdolahi
Shirin Abdolahi

Reputation: 1067

Before your text use <pre> tag. <pre> tag renders text in the format you type. But simple html tags removes extra spaces. Or even simpler, use &nbsp instead of your spaces.

<th width="6%" class="textLeft width100px borderTopNone" style="vertical-align:top;font-size:14px; white-space: nowrap;" colspan="2">
    HELLO&nbsp&nbspWORLD
</th>

Or :

<th width="6%" class="textLeft width100px borderTopNone" style="vertical-align:top;font-size:14px; white-space: nowrap;" colspan="2">
    <pre>HELLO  WORLD</pre>
</th>

Upvotes: 1

jfrej
jfrej

Reputation: 4648

You can use the word-spacing CSS property, for example:

word-spacing: 1em;

Read more here:

Here's an example on jsfiddle - the second table cell has extra spacing.

You can also use white-space: pre as suggested by others but it might not work in older IEs. And I can see you already set white-space to nowrap.

Or you can use &nbsp; to hard-code the space but it's usually better to use CSS.

Upvotes: 1

Anonymous
Anonymous

Reputation: 10216

You can use the &nbsp; character entity as non breaking space - DEMO

&nbsp; - A common character entity used in HTML is the non breaking space.

HTML:

<th width="6%" class="textLeft width100px borderTopNone" style="vertical-align:top;font-size:14px; white-space: nowrap;" colspan="2">HELLO&nbsp;&nbsp;WORLD</th>

Upvotes: 1

Kyojimaru
Kyojimaru

Reputation: 2724

add style

white-space: pre

for the containing element

Upvotes: 3

Related Questions