Skip to content
AITroveRead. Build. Understand.
Make this comfortable

HTML wbr: suggest a break inside an unbroken identifier

Last updated: 1 Oct 20267 min read
tutorial
IntermediateBy AITrove Editorial

The wbr element marks a position where the browser may break a long string onto another line.

Use it in a concrete workflow

A narrow audit panel displays a generated shipment reference that has no spaces. Adding a possible break after its fixed prefix keeps the identifier readable without changing the characters that users copy. The browser may choose another break based on available width. If a code must remain one unbroken unit for machine parsing, store and transmit its original value independently rather than scraping text from a rendered panel.

html
<p>Shipment reference:
  <code>WEST47-<wbr>DEPOT19-<wbr>REVIEW204</code>
</p>

Behavior and ownership

A soft break is a layout opportunity, not a delimiter in the business identifier. The code remains the same sequence of visible characters; test selection, copy, and screen-reader reading for the intended audience.

Performance and maintenance

Wbr adds tiny DOM overhead. It cannot repair a container with a fixed width or a design that clips overflow, so check the complete page at mobile sizes.

Common Mistakes

  • Do not insert spaces that alter an identifier's meaning.
  • Do not expect wbr to force a line break at every width.
  • Do not use it to conceal a broader overflow problem.

Connected lessons

Continue with HTML pre and code: preserve source layout without hiding the meaning.

html
semantics
Storage details