Table of Content
The <wbr> tag in HTML helps the browser decide where it can break a word. It does not force a break, but it shows a place where a break is possible if the text reaches the edge of the container.
Understand the <wbr> Tag in HTML
The <wbr> tag is a short empty element that marks an optional break point. The browser will break the word only when it reaches that point in the line.
Here is the basic tag:
<wbr>Most modern browsers support <wbr> well. Older versions of Internet Explorer ignored it, but newer versions render it as expected.
Mobile browsers also apply it to make word wrap better on narrow screens.
Here is a quick example:
<p>Antidisestablish<wbr>mentarianism is a long word.</p>Here, the browser break the word between Antidisestablish and mentarianism if there is no space left in the line.
Use wbr Tag for Long Words or URLs
The <wbr> tag works well when you need to prevent layout issues from long content. A long URL or word can push the page wider than the screen.
So, the <wbr> inside the text guides the browser to break it in the right place.
For example:
<p>https://www.example.com/this<wbr>isavery<wbr>long<wbr>url</p>The browser can break the link into more lines without cuts at random spots.
The Differences Between <wbr> Tag and Other HTML Line Break Methods
The <wbr> tag is different from <br> and CSS word-break rules.
<br>forces a break at that point, no need for the space left.- CSS word-break or overflow-wrap rules set global break behavior for all text.
<wbr>gives the browser a choice but does not force it.
Use <wbr> when you want optional breaks inside long words or URLs while <br> when you must split content at a fixed point.
Also, you can use the CSS rules when you need consistent breaks across all elements.
Here is a table that shows you the key differences between them:
| Method | Forces Break | Optional Break | Global Control | Browser Support |
|---|---|---|---|---|
<br> | Yes | No | No | High |
<wbr> | No | Yes | No | High |
| CSS word-break | Depends | Depends | Yes | High |
Examples
Break in a Long Technical Term:
<p>Electro<wbr>encephalo<wbr>graphically measured brain activity</p>This example shows a long scientific term broken into smaller, readable parts. The browser will break the term only when space runs out.
Optional Break in a URL:
<p>https://www.longdomain.com/section<wbr>name<wbr>subcategory<wbr>deepcontent</p>Here the <wbr> tag lets the URL split without breaks in the middle of words or numbers. This helps avoid layout shifts.
Complex Sentence With Optional Break Points:
<p>This sentence has a super<wbr>califragilisticexpialidocious word for test purposes</p>The <wbr> tag offers a natural break in the long word without effect on how the rest of the sentence appears.
Wrapping Up
In this article, you learned what the <wbr> tag does and how it helps control text breaks in HTML.
Here is a quick recap:
- The
<wbr>adds an optional breakpoint inside a word. - It does not make the break happen, but lets it happen when there is little space.
- Browsers support it on many devices.
FAQs
What is the <wbr> tag in HTML?
<p>Averylongword<wbr>Anotherword</p>
This helps avoid layout issues with long strings without breaking them unless necessary.How do you use the <wbr> tag in HTML?
<p>supercalifragilistic<wbr>expialidocious</p>
The browser will break the word at that point only when space runs out.What is the difference between <wbr> and <br> in HTML?
<p>Hello<br>World</p>
<p>Hello<wbr>World</p>
Use <wbr> for optional breaks and <br> for fixed breaks.Similar Reads
Forms need instructions so users know what to enter. You use the HTML label tag to give names to input…
Use the HTML b tag to make text bold without giving it extra meaning. It adds visual weight only. Understand…
The HTML <strong> tag shows strong importance. This tag gives semantic meaning to text. Screen readers and search engines recognize…
The <svg> tag in HTML helps you draw graphics that scale cleanly at any size. You can animate shapes and…
In this article, you will learn what HTML meta tags are and how they work. You also see how they…
The heading elements define a content structure in HTML. Use <h1> to <h6> to show levels. <h1> means the main…
The HTML hidden attribute hides elements from users but keeps them in the code. You can use it when you…
The HTML ARIA attributes help users with disabilities use websites. These attributes describe roles and states for tools. Understand the…
The HTML tabindex Attribute lets you change the tab order on a web page. It helps control keyboard access. What…
The HTML span tag acts as a simple container for inline text or other inline elements. It groups text and…