Inline
HTML5
Void Element
The word break opportunity element represents a position within text where the browser may optionally break a line, though its line-breaking rules would not otherwise create a break at that location.
Interactive code playground requires JavaScript. Here's the code:
<p>The URL is https://www.<wbr>example.<wbr>com/<wbr>very/<wbr>long/<wbr>path/<wbr>to/<wbr>resource</p>
<!-- XHTML (also valid in HTML5) -->
The <wbr> element is a void element (self-closing), with no content.
Interactive code playground requires JavaScript. Here's the code:
<p>Visit https://www.<wbr>example.<wbr>com/<wbr>documentation/<wbr>getting-<wbr>started/<wbr>installation/<wbr>index.<wbr>html</p>
Interactive code playground requires JavaScript. Here's the code:
<p>File location: /Users/<wbr>username/<wbr>Documents/<wbr>Projects/<wbr>website/<wbr>src/<wbr>components/<wbr>Header.<wbr>jsx</p>
Interactive code playground requires JavaScript. Here's the code:
<code>const user<wbr>Authentication<wbr>Service<wbr>Instance = new User<wbr>Authentication<wbr>Service();</code>
Interactive code playground requires JavaScript. Here's the code:
<p>Contact: very<wbr>long<wbr>email<wbr>address<wbr>@<wbr>subdomain.<wbr>example.<wbr>com</p>
Interactive code playground requires JavaScript. Here's the code:
<p>Chemical compound: poly<wbr>tetra<wbr>fluoro<wbr>ethylene (PTFE)</p>
Interactive code playground requires JavaScript. Here's the code:
<code>get<wbr>User<wbr>Authentication<wbr>Token<wbr>From<wbr>Local<wbr>Storage()</code>
Interactive code playground requires JavaScript. Here's the code:
<div class="api-endpoint">
<h4>Endpoint</h4>
<code>POST /api/<wbr>v2/<wbr>users/<wbr>{userId}/<wbr>preferences/<wbr>notifications/<wbr>settings</code>
</div>
Interactive code playground requires JavaScript. Here's the code:
<div class="path">
<p><strong>Installation Directory:</strong></p>
<code>C:<wbr>Program Files<wbr>Company Name<wbr>Application<wbr>Version 2.0<wbr>bin<wbr>executable.<wbr>exe</code>
</div>
Interactive code playground requires JavaScript. Here's the code:
<pre><code>npm install @<wbr>organization/<wbr>very-<wbr>long-<wbr>package-<wbr>name-<wbr>for-<wbr>specific-<wbr>purpose</code></pre>
Interactive code playground requires JavaScript. Here's the code:
<p>Connection string:</p>
<code>mongodb+srv://<wbr>username:<wbr>password@<wbr>cluster0.<wbr>mongodb.<wbr>net/<wbr>database?<wbr>retryWrites=<wbr>true&<wbr>w=<wbr>majority</code>
<!-- Optional break (browser decides) -->
< p > https://www. < wbr > example. < wbr > com </ p >
Breaks only if needed for wrapping.
<!-- Forced break (always breaks) -->
Always creates a line break.
Interactive code playground requires JavaScript. Here's the code:
<style>
.container {
width: 300px;
border: 1px solid #ddd;
padding: 10px;
}
</style>
<div class="container">
<p>Without <code><wbr></code>:</p>
<p>https://www.verylongdomainname.com/path/to/resource</p>
<p>With <code><wbr></code>:</p>
<p>https://www.<wbr>very<wbr>long<wbr>domain<wbr>name.<wbr>com/<wbr>path/<wbr>to/<wbr>resource</p>
</div>
Place <wbr> at logical break points:
Interactive code playground requires JavaScript. Here's the code:
<!-- Break at punctuation -->
<p>example.<wbr>com/<wbr>path/<wbr>file.<wbr>html</p>
<!-- Break in camelCase -->
<code>get<wbr>User<wbr>Data<wbr>From<wbr>API()</code>
<!-- Break at hyphens/underscores -->
<code>very_<wbr>long_<wbr>variable_<wbr>name</code>
You can achieve similar effects with CSS:
Interactive code playground requires JavaScript. Here's the code:
<style>
.break-word {
word-break: break-word;
}
.break-all {
word-break: break-all;
}
.overflow-wrap {
overflow-wrap: break-word;
}
</style>
<div style="width: 200px; border: 1px solid #ddd; padding: 10px;">
<p class="break-word">https://www.example.com/very/long/path</p>
</div>
<!-- Fine-grained control over break points -->
< p > example. < wbr > com/ < wbr > path </ p >
<!-- Breaks anywhere needed -->
< p style = " word-break: break-all; " > example.com/path </ p >
<wbr> is semantically better than using zero-width space character:
<!-- Using Unicode character U+200B -->
Especially useful for mobile layouts:
Interactive code playground requires JavaScript. Here's the code:
<style>
.mobile-text {
max-width: 300px;
border: 1px solid #ddd;
padding: 10px;
}
</style>
<div class="mobile-text">
<p>Repository: github.<wbr>com/<wbr>organization-<wbr>name/<wbr>project-<wbr>repository-<wbr>name</p>
</div>
Screen readers ignore <wbr> elements - they don’t announce breaks or pauses.
The element is purely for visual presentation:
<!-- Screen readers read this as one continuous string -->
< p > example. < wbr > com/ < wbr > path </ p >
<!-- Read as: "example.com/path" -->
Use <wbr> when you have:
Long URLs
File paths
Technical identifiers
Long words or compound words
Code snippets
Email addresses
Don’t use <wbr> for:
Regular text content
Forcing line breaks (use <br>)
Creating visual spacing
Short words
<wbr> has minimal performance impact as it’s just a hint to the browser’s line-breaking algorithm.
Browser Version Notes Chrome 1+ Full support Firefox 3+ Full support Safari 4+ Full support Edge 79+ Full support IE 5.5+ Partial support
The <wbr> element has excellent browser support. Older browsers that don’t recognize it simply ignore it harmlessly.