Text wrap after a certain number of characters

liunx

Guest
Hey,

I don't know if this is possible, but I'd like to make it so that, after a certain number of characters, a body of text will carry to the next line. Is there a tag for this?

Thanks,

kendoif you use the <p></p> tag for all the text you can then set the width of the <p> with css.

if you need it for just one paragraph use some thing like
<p id="setwidth">text here</p>

then in the css

p#setwidth {
width: 100px
}I think you'll need to look into some Server Side Scripting for that (PHP for example). There is no "tag" that can do that, tags are more or less labels. I'd look into counting words though instead of characters as you'd end up splitting up words.andy's solution worked. php is also another clever idea i didn't even think of :)
thanks guysI have found that in some browsers if you have an abnormally large word (a word which takes up more pixels than the width of the paragraph or div) it will spill over the edge regardless of what you have overflow set to wrap or hide, with scroll it works fine (for obvious reasons).

If you find that to be a problem, a quick php or javascript scan of the text withn the page can help you find trouble words/strings-without-spaces and "force" spaces into the right places to wrap.Instead of using px as width unit, set it in em - then you would have the same amount of characters per line for any user font size settingI think that would still produce the same results with the problem of non-wrapping long strings. I'll get to work to see if it does though...
 
Back
Top