[whatwg] Interaction of <wbr> and CSS white-space

fantasai fantasai.lists at inkedblade.net
Mon May 16 01:09:55 PDT 2011

On 05/14/2011 12:41 AM, Boris Zbarsky wrote:
> On 5/14/11 3:29 AM, Jukka K. Korpela wrote:
>> For example, when mentioning URLs in the text of a document, you
>> normally want to prevent line breaks in them by default and only allow
>> line breaks at specific points, as in
>> http://www.whatwg.org/<wbr>specs/<wbr>web-apps/<wbr>current-work/<wbr>multipage/
>> Oops, my newsreader introduced a line break after a hyphen. And such
>> behavior is common in web browsers as well. So it is natural to wrap
>> urls in text in <span class="url">...</span> with CSS rule .url {
>> white-space: nowrap; }.
> Except that browsers don't support that, for the most part.
> The problem you describe is one of breakpoint prioritization. I have no problem with <wbr> getting priority over breakpoints
> that the browser determines itself. CSS3 Text has explicit language to the effect that not all breakpoint opportunities are
> equal in section 7.1.
>> Anyway, the idea is to disallow line breaks (that would otherwise be
>> allowed by line breaking rules, whatever they might be in each
>> situation) _except_ where explicitly allowed by <wbr>.
> This can be done by simply using "white-space: normal" and having UAs prioritize breaks at <wbr> over other linebreaks, no?

Yes, but you'd get unexpected breaks where <nowrap> isn't used.
IIRC (this is going back > 10 yrs) <wbr> isn't supposed to have
a higher priority than spaces.

>> The HTML specs cannot dictate what CSS specs do
> They're trying to, is my point. As an implementor I then have to reconcile the conflict somehow. My current plan if it's up to
> me is to do so by completely ignoring the part of HTML5 that's conflicting with CSS here.

I agree that the HTML spec should not be trying to contradict or override
the CSS specs, and suggest that the HTML editor make a habit of posting
such issues to www-style to bring them to the CSS spec editors' attention
instead of merely writing overrides into the HTML spec...

>> So maybe the best way to convey the message is to remove the reference
>> to white-space and add a note on the _HTML_ element <nobr> (even if it
>> is kept as obsolete - the spec should still specify its meaning):
>> "The wbr element specifies a line breaking opportunity even when used
>> inside a nobr element."
> I would be fine with that, if it's useful. Is it useful?

Yes, if you wanted to control breakpoints, <nobr>...<wbr>...</nobr>
was very useful.

I think it's possible to deal with the rendering requirements by

wbr { content: '\8203' /* zwsp */;
       text-wrap: normal; }

Slightly off-topic: in CSS3, there is an 'avoid' value for 'text-wrap',
which is designed to solve problems similar to those currently dealt
with by using <nobr>/<wbr> combinations.


More information about the whatwg mailing list