Skip to content
Tutorials Center
My learning

Topics

HTML Reference ยท Inline Text

The <wbr> element

Reference for the HTML <wbr> element: optional line-break points inside long words, URLs and identifiers, how it compares to &shy; and <br>, and technical details.

The <wbr> element marks a line-break opportunity: a place inside a long run of text where the browser may wrap to the next line if space runs out. If the line fits, nothing happens. It is a void element, so it has no content and no end tag.

Browsers normally break lines only at spaces and some punctuation, so long URLs, file paths, code identifiers and compound words can overflow narrow containers. <wbr> gives them safe places to wrap, without adding a hyphen.

HTML
<p>See docs.example.com/<wbr>guides/<wbr>getting-started</p>

Try it

Optional break points

The first box overflows. The second wraps between the parts of the name with no extra characters. The third uses the soft hyphen entity &shy;, which adds a visible hyphen when the word breaks.

Attributes

This element has no attributes of its own. It accepts the global attributes, although they rarely matter on an element with no content.

Usage notes

  • <wbr> vs &shy;. Both mark optional break points. <wbr> adds nothing when it breaks, which suits URLs and code. The soft hyphen &shy; shows a hyphen at the break, which suits words in running text.
  • <wbr> vs <br>. <br> always starts a new line; <wbr> only allows one.
  • Copying is safe. <wbr> adds no characters, so copied URLs and identifiers stay intact.
  • When you don't control the text. For user-generated content, CSS such as overflow-wrap: anywhere or word-break: break-word handles long strings automatically, and hyphens: auto adds language-aware hyphenation.
  • Where to place it. Good spots in URLs are after slashes and before dots or question marks; in code, between words of a camelCase or snake_case name.

Technical summary

Content categories Flow content, phrasing content
Permitted content Nothing; it is a void element
Tag omission Must have a start tag and must not have an end tag
Permitted parents Any element that accepts phrasing content
Implicit ARIA role No corresponding role
DOM interface HTMLElement
Default display None; it generates no box, only a possible break point

Browser support

Supported in every current browser.