Link to home
Start Free TrialLog in
Avatar of PieP
PieP

asked on

How do i write blank spaces?

How do i write blank spaces in HTML?
I know   works but if I want 10 spaces it looks ugly
Avatar of KenAdney
KenAdney

Some folks create a gif of the appropriate size & insert that.
ASKER CERTIFIED SOLUTION
Avatar of seanpowell
seanpowell
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The width property doesn't apply to <span> elements (with their default display). A bug in MSIE lets authors get away with it.

There are several techniques which might be considered good, but are dependent on the context.

Why do you want blank spaces? (Show us the data you are trying to layout)
<span style="white-space:pre">          </span>
you really should use 10 &nbsp; for what you want, if you want to have a 10 space on the same paragraph or something like that you may use margin-left css property, <blockquote>TEXT</blockquote>, white css borders, etc...
&nbsp; is the normal way, or you can use CSS letter-spacing: or word-spacing:
<span style="word-spacing:0.6em">Bonjour Hola! Servus</span>
* &nbsp; is not something you should use (for this)
* Blockquote is something you certainly should not use unless its a quote
* margin might be apropriate - but it depends on the data that you are trying to lay out
* &nbsp; is only the "normal" way becuse its a quick hack that 'works' in some places.
you wan use <pre>
ex.
I have 10 spaces after this.<pre>          </pre>. Did you see them?
As others have remarked, it really depends upon the context.

Using a div or span purely for the purpose of adding spacing is bad use of markup.

> I know &nbsp; works but if I want 10 spaces it looks ugly

How it looks in source is immaterial.

There are many alternatives -- for instance, if you are wanting to provide indentation of a paragraph, then, yes, inserting ten nonbreaking spaces is quite ugly when you can use something like p { text-indent:3.5em;} instead.

Please tell us precisely what it is you're wanting to do and why.

Hi,

There's loads of ways to do this, the best one depends on where you need the space and why.  Most of the options have already been covered, but I'll just add one more.  To add 10 characters worth of spacing after some text, try this:

<span style="margin-right:10em">
This text has 10 chars of spacing to the right
</span>
This text appears after the spacing.

Good luck!
Thanks - glad to help.