Bug 64005 - Make a sane CSS implementation of <wbr>
Summary: Make a sane CSS implementation of <wbr>
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: http://www.w3.org/Bugs/Public/show_bu...
Depends on:
Blocks: 26414
  Show dependency treegraph
Reported: 2011-07-06 10:10 PDT by Leif Halvard Silli
Modified: 2024-02-10 09:25 PST (History)
5 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Leif Halvard Silli 2011-07-06 10:10:33 PDT
Please drop the current special casing of <wbr> and instead implement the following CSS:

/* Outside NOBR:  */

/* Inside NOBR:  */
nobr wbr

For mor info, see the following two test pages:

(1) http://www.malform.no/testing/html5/nobr%2Bwbr
(2) http://www.malform.no/testing/html5/nobr

PS: Those test pages seems to document that Webkit doesn't properly support the Zero Width Space character (&#x200B;), so you may need to fix that as well, before the 'Inside NOBR' style will work.
Comment 1 Alexey Proskuryakov 2011-07-06 14:34:20 PDT
Is your proposal in accordance with HTML5?
Comment 2 Leif Halvard Silli 2011-07-07 23:24:01 PDT
(In reply to comment #1)
> Is your proposal in accordance with HTML5?

Yes. Citing HTML5: http://dev.w3.org/html5/spec/rendering.html#rendering

]]  The wbr element is expected to override the 'white-space' property and always provide a line-breaking opportunity. [[
wbr{white-space:pre /* This rule overrides white-space ...*/} ;-)

Btw, there is a Mozilla bug about implementing  <wbr> as CSS and XBL, where Anne van Kesteren stated: 

]]     If this is going to be implemented using CSS, it should be like:
       # wbr:before { content:"\200B"; white-space:normal; }
[[    See: https://bugzilla.mozilla.org/show_bug.cgi?id=178671#c9

In fact, I hereby withdraw my proposal in Comment #0 and propose this rule instead:

   wbr { content:"\00200B"; white-space:normal; } /* eventually in addition, because foo{content:"bar"} is not well supported: */
  wbr:before{content:"\00200B"} /* to make up for bad support for generated content: */

Those rules should solve it  - and *does* solve it in Opera. In principle, it solves it in Firefox too. However, <wbr> is very difficult to style <wbr> in Firefox - it reacts to very few properties.  So in order to verify that it - in principle - works in Firefox too, I had to test it on a <span/> element.  It also *in principle* solves it in IE8 (verified, again, with a span element). An it does - for real - solve it in IE9. I f you want to see this for yourself - and I wrote this test case very much as a response to your question  - you can see here: 


That page is cross-browser. But the Webkit essence of that page goes like this (because it focuses on *current* Webkittens ...):

/*inline-block collapses the space character See explation on the page). */

During the writing of that page, it became clear that Webkit's current implementation is quite buggy. Se for instance this test:


That bug do - for me - confirm that we need a sane CSS based implementatino rather than the adhoc solution Webkit seems to have today.

There seems to be this myth around that CSS is not enough if we want to implement <wbr>. The myth finds nourishment by in the fact that the HTML5 Editor do not want to spec at specific CSS rule, because he is not certian which one would work, it seems. And another myth source: When Maciej filed the bug which made <wbr> a valid HTML5 element, he claimed that Webkit's code demonstrated that it was necessary to break CSS in order to implement <wbr>.

However, when I created the wbr-crossbrowser page above, then CSS stylability was the key to creating a workable solutions. Fortunately, <wbr> is more stylable in Webkit than it is in Firefox.  Hence my wbr-crossbrowser page was able to seemingly fix the bug. Which agian confirms ...
Comment 3 Leif Halvard Silli 2011-07-08 00:11:15 PDT
The CSS I proposed could also have fixed bug 26414
Comment 4 Leif Halvard Silli 2011-07-08 00:46:23 PDT
The styles I propose do not break with bug 7452:

Comment 5 Ian 'Hixie' Hickson 2012-01-13 15:46:29 PST
The HTML standard now defines the <wbr> and <nobr> elements in terms of CSS.
Comment 6 Ahmad Saleem 2024-02-10 09:25:09 PST
Web-Spec: https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3

We don't following UA rule:

nobr wbr { white-space: normal; }

While we have following:


nobr {
    white-space: nowrap;