<div> that breakes text

R

Rafal 'Raf256' Maj

Hi, how can I use <div> that will break too long lines as table do, i.e. I
have realy long text
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

or i have a <div><pre>... situation, and I want too long lines to be hard-
broken to fit div width.
 
M

Mark Parnell

Hi, how can I use <div> that will break too long lines as table do, i.e. I
have realy long text
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Get your script to insert spaces after every n consecutive non-breaking
characters.

A table doesn't wrap long text any more than any other element does.
 
J

Jukka K. Korpela

Mark Parnell said:
Get your script to insert spaces after every n consecutive
non-breaking characters.

I guess the question most often arises when someone has souped up a
guestbook script or found one, then sees what happens when someone
types a long string without spaces.

There are usually more serious problems than that, then, and what is
probably needed is to reconsider what's the big idea in a guestbook
script (there's actually no serious shortage of virtually empty
guestbooks on the Web) and then, maybe, finding a _good_ guestbook
script from a suitable distribution site. The details depend on the
authoring environment as usual.
 
R

Rafal 'Raf256' Maj

(e-mail address removed)
I guess the question most often arises when someone has souped up a
guestbook script or found one, then sees what happens when someone
types a long string without spaces.

Som there is no (X)HTML way to make an element that will force braking of
lines?

Wouldn't that be a good idea to add element like this into next CSS?
 
J

Jukka K. Korpela

Rafal 'Raf256' Maj said:
Som there is no (X)HTML way to make an element that will force
braking of lines?

Surely. <br> (or <br />) to begin with. As we move to _allowed_ line
breaks, things get rather complicated. So make sure you're solving the
right problem. Then, re-check that. Are you sure you are doubly sure?
Click here to continue. Oops, try this:
http://www.cs.tut.fi/~jkorpela/html/nobr.html#suggest
Wouldn't that be a good idea to add element like this into next
CSS?

CSS has no elements.
 
T

Toby A Inkster

Rafal said:
Som there is no (X)HTML way to make an element that will force braking of
lines?

Breaking lines partway through a word is generally considered undesirable.
 
M

Marc Nadeau

Mark Parnell a écrit:
Get your script to insert spaces after every n consecutive non-breaking
characters.

A table doesn't wrap long text any more than any other element does.

An example of such a PHP function:

<?php
/* insert a space (or any $separator ) every $lenght caracter */
/* only for words longer than $lenght */

function cutLongWord($string, $lenght, $separator) {
if ($separator == null) {
$separator= ' ';
}
return preg_replace('/([^ ]{'.$lenght.'})/si','\\1' .$separator , $string);
}
?>

It's a rough sketch of a function that could be refined but should face most
situations where you have posters with a broken spacebar.


Bonne chance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top