Search code examples
unicodewbr

Unicode alternative for <wbr> tag


I am looking for Unicode solution which will be an alternative to <wbr> tag in following regards:

  1. Allowing line breaks at given position.
  2. Browser can find string in the page even when 'broken' apart.
  3. When copied from page, these characters will not be transfered.

This is exactly what <wbr> does in modern browsers. &shy;, &#x00ad; and &#x200b; does not seem to conform.

Here is a http://jsfiddle.net/qY6mp/7/ to demonstrate.

I will be thankful for any pointers.


Solution

  • The Unicode counterpart of <wbr> is U+200B ZERO WIDTH SPACE, representable in HTML as &#x200b; if you don’t want or can’t use it as such. It’s not clear from the question why you think it does not conform. The main problem with it as questionable support in IE 6, but this is not a conformance issue.

    According to Unicode line breaking rules, U+200B “is used to enable additional (invisible) break opportunities wherever SPACE cannot be used”. HTML specifications do not require conformance to the Unicode standard, in this issue or otherwise, but modern browsers generally implement U+200B this way.

    What happens when text is copied from an HTML document is outside the scope of specifications. The same applies to requirement 2 in the question. Since generally copy and paste copies characters, including zero width characters, and search functionality operates on characters, requirements 2 and 3 are really asking for a character that does not behave like character.

    Note that hyphenation is completely different issue.