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
The breadcrumb in HTML shows a path through a site and marks the place of a page inside it. It…
The HTML bdi tag marks text that has an unknown or mixed direction. It makes sure that this part does…
The <details> tag hides content and shows it when needed. It helps organize long pages. The tag shows extra info…
The abbr tag refers to an abbreviation in HTML. It helps you save space and improve accessibility. The screen readers…
In this article, you will learn what HTML meta tags are and how they work. You also see how they…
Skip link in HTML helps users jump to important parts of a web page without delay. What is an HTML…
The HTML head tag contains information and loads tools for the web page. What Is the <head> Tag in HTML?…
The <hr> tag in HTML gives you a fast way to split content with a clean horizontal line. You may…
The nav tag defines a navigation block in HTML. It holds main links to other parts of your site. Search…
HTML builds web pages. It does this with elements and tags. Many new learners confuse them, so you need to…