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 ­ 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.
<p>See docs.example.com/<wbr>guides/<wbr>getting-started</p>
Try it
The first box overflows. The second wraps between the parts of the name with no extra characters. The third uses the soft hyphen entity ­, 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­. Both mark optional break points.<wbr>adds nothing when it breaks, which suits URLs and code. The soft hyphen­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: anywhereorword-break: break-wordhandles long strings automatically, andhyphens: autoadds 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.
Related
<br>โ a forced line break- Character entities โ including
­and <pre>โ preformatted text that keeps its line breaks- Lesson: Times, Data Values and Ruby Text
- Lesson: HTML Entities