Template:Wbr/doc

From Wikivahdat
< Template:Wbr
Revision as of 12:06, 21 January 2024 by Mahdipor (talk | contribs) (Created page with "{{Documentation subpage}} <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see Wikipedia:Wikidata) --> {{High-use}} ''Wbr'' indicates a ''word break'' opportunity. This template includes the HTML tag [https://www.w3.org/TR/html5/text-level-semantics.html#the-wbr-element {{tag|wbr|s}}], which is used to tell the browser of an optional, non-hyphenated line-break. It can be used with: * {{tlx|nbsp}} or the equivalent <c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Wbr indicates a word break opportunity. This template includes the HTML tag <wbr />, which is used to tell the browser of an optional, non-hyphenated line-break. It can be used with:

  • {{nbsp}} or the equivalent &nbsp; (non-breaking space)
  • {{nowrap}} or the equivalent <span style="white-space: nowrap;">...</span> or <span class="nowrap">...</span> (character string that will not break even at a normal space)

to carefully control line-breaking where this is important.

This template can safely be substituted, though there is no particular reason to do so. For breaking up long words, use {{Soft hyphen}} instead.

Usage

Use is simple; there are no parameters:

or

Controlling line-breaking in infoboxes

This template can be used to cause an indentation after a linebreak, in unbulleted lists inside infoboxes and in tables with constrained cell widths, by using {{wbr}}&nbsp; between words in an entry, so that when they wrap they are not mistaken for separate entries. See example infobox to the side.

Example infobox (rendered to the side of the example code): Template:Infobox film

{{Infobox film|
|name=Test Infobox II: The Revenge
|...
|starring={{Plainlist|
* Jane Smith
* {{nobr|Johannes-Friedrich}}{{wbr}}&nbsp;Zauberzunge{{wbr}}&nbsp;{{nobr|von der Hasenpfeffer}}
* John Garcia
}}
|...
}}

Breaking up slashes

Template:See When there are long words on both sides of a slash, this template may be used to induce a line break after the slash.

installation/​execution
installation/{{wbr}}execution

Technical details

This template encapsulates the code <wbr />&#8203;, i.e. the HTML5 line break opportunity element followed by the HTML character entity for the Template:Unichar character. This approach is superior to using either one or the other in isolation, for increased browser support. The <wbr /> element is compatible with all browsers except Internet Explorer inclusive of and Template:Em version 7 (Template:As of). Meanwhile, the ZWS character is compatible with all browsers except Internet Explorer Template:Em (but not inclusive of) version 7. Thus, between the two approaches, the dual use of which has no ill effects, this template works in all browsers still likely to be in use, including Internet Explorer regardless of version.