Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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?



Re: custom WORD-BREAK

Scripsit Ben:

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

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.)

Quoted text here. Click to load it

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.

Jukka K. Korpela ("Yucca")

Re: custom WORD-BREAK

Ben wrote:

Quoted text here. Click to load it

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])/', ',&#8203;$1', $text);

Toby A Inkster BSc (Hons) ARCS
Contact Me ~
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

Re: custom WORD-BREAK

Quoted text here. Click to load it

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


Re: custom WORD-BREAK

Scripsit Toby A Inkster:

Quoted text here. Click to load it

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.

Jukka K. Korpela ("Yucca")

Site Timeline