custom WORD-BREAK

B

Ben

Hi,

Does anyone know if there is a way of specifying a custom "WORD-BREAK"
in css? I can set it to normal, which breaks on spaces, or All, which
breaks anywhere, but ideally I would like it to break on spaces or
commas only...

Is there a way, shoer of processing the strings to turn all commas
into spaces beforehand?

Cheers,

ben
 
J

Jukka K. Korpela

Scripsit Ben:
Does anyone know if there is a way of specifying a custom "WORD-BREAK"
in css?

There is none. In fact, the word-break property isn't part of CSS at all; it
is just in a CSS 3 draft and partly implemented in IE.
I can set it to normal, which breaks on spaces, or All, which
breaks anywhere, but ideally I would like it to break on spaces or
commas only...

You cannot do such things in CSS. As a practical move, you could simply add
<wbr> after each comma. (Stay tuned to mourning complaints about <wbr> being
nonstandard. It's not allowed to mention it without making a liturgic remark
about its not being in HTML specifications.)
Is there a way, shoer of processing the strings to turn all commas
into spaces beforehand?

If you turn commas into spaces, you change the content. What's really
relevant here? As usual, a URL etc.

The odds are that you should simply stop creating the problem (either by
removing artificial width restrictions or by doing something to long strings
with no whitespace), but it's difficult to help with that without seeing how
you are now creating it.
 
T

Toby A Inkster

Ben said:
Is there a way, shoer of processing the strings to turn all commas
into spaces beforehand?

Wouldn't a better conversion be from a comma to "comma-space".

In PHP, this would be:

$text = str_replace(',', ', ', $text);

or even better:

$text = preg_replace('/\,([^\s])/', ', $1', $text);

Anyone know if Internet Exploder supports ZWSP yet?

$text = preg_replace('/\,([^\s])/', ',​$1', $text);

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
 
B

Ben

Ben said:
Is there a way, shoer of processing the strings to turn all commas
into spaces beforehand?

Wouldn't a better conversion be from a comma to "comma-space".

In PHP, this would be:

$text = str_replace(',', ', ', $text);

or even better:

$text = preg_replace('/\,([^\s])/', ', $1', $text);

Anyone know if Internet Exploder supports ZWSP yet?

$text = preg_replace('/\,([^\s])/', ',​$1', $text);

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

I thought I might have to do that - you're right, it is a simple fix!
Cheers,

Ben
 
J

Jukka K. Korpela

Scripsit Toby A Inkster:
Anyone know if Internet Exploder supports ZWSP yet?

IE has kind-of supported ZWSP a long time, but up to IE 6 it wants to
_render_ its glyph, so things go wrong if the font in use doesn't contain an
(empty) glyph for it, displaying a rectangle instead. This seems to have
been fixed in IE 7. Thus, in terms of browser support, <wbr> is _far_ more
practical - it works on the great majority of browsers, and it does no harm
(no nasty rectangle) when it doesn't work.
 

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,598
Members
45,157
Latest member
MercedesE4
Top