spacing text

They have: 20 posts

Joined: Jan 2007

how do i make more than one space in text in a webpage?
pressing more than one spacebar just doesnt work!

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

What you need is a "Non-Breaking Space", in actual HTML code, it is represented by   In a WYSIWYG editor like dreamweaver, there is usually a key combination that will insert one for you, I think it is CTRL-SPACE.

-Greg

He has: 629 posts

Joined: May 2007

Multiple spaces, line-ends, and tabs normally collapse to a single space in HTML. You can prevent that by using the PRE element, or by declaring "white-space: pre;" in CSS.

If you just want to increase word spacing in a group of words, use the "word-spacing" property in CSS for better control of the amount of space added.

Cordially, David

Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;

He has: 1,380 posts

Joined: Feb 2002

When you want a space you can do this:

<p>Here's some text...and some more.  But NOW here's two&nbsp;&nbsp; spaces!</p>
'

The   character is literally a space. Any number you want, just use the   as a spacebar-hit.

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Why are you trying to insert an extra space? All of the above answers are good ones, but I'm thinking from a semantic perspective. What's the purpose of the nbsp? I don't really think there are a lot of reasons for using nbsp's but we might be able to think of some. If it's a presentational issue then it should be handled using CSS. If it's because you were taught to type with two spaces after a period, then you should try to unlearn that habit (it's a hold over from old typewriters and isn't necessary anymore).

David - does word-spacing actually work? I'm going to have to try that out... (I mean, is it supported by browsers)

demonhale's picture

He has: 3,278 posts

Joined: May 2005

It is supported Meg, the same properties as letter-spacing which I seem to use a lot lately... it's at Topic 16.4 here http://www.w3.org/TR/REC-CSS2/text.html

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

No, I mean does it actually work in web browsers? supported != part of the w3c spec. I know it's in the spec. Letter-spacing is in there too but isn't supported by browsers

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Well surprise surpirse, they actually do work! And even in IE 6!

demonhale's picture

He has: 3,278 posts

Joined: May 2005

Well I also mean supported in browsers as far as I remember, as in I use it all the time... I think my previous post wasn't clear enough... sorry bout that... The link was suppose to clarify you with it's property...

He has: 629 posts

Joined: May 2007

Thanks for the test page, Megan.

Checking on Win xp pro, your page shows:

Letter-spacing works in IE 5.01 and up; Firefox 2, Opera 9, Netscape 7.2, and Moz 1.7.
Word-spacing works in the above except for IE 5.01 and IE 5.5.

Incidentally, I sometimes use a negative letter-spacing for headings. Depending on the font, it can give a nice effect. Letter-spacing: -1px; is usually enough.

Cordially, David.

Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

That's a good idea, David! I'll have to try that sometime.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.