The <wbr> (Word Break Opportunity) tag in HTML5 specifies a position within text where the browser may break a line, even if its default line-breaking rules wouldn't allow it. This is particularly useful for managing the display of long words or URLs that might otherwise overflow their containers.
To insert a word break opportunity, place the <wbr> tag at the desired location within the word:
<p>Antidisestablishmentarianism<wbr> is a long word.</p>
Rendered Output:
Antidisestablishmentarianism
In this example, the browser may break the word "Antidisestablishmentarianism" at the position where the <wbr> tag is placed, depending on the available space.
Long URLs can cause layout issues, especially on narrow screens. By inserting <wbr> tags at appropriate positions, you can allow the browser to break the URL into multiple lines without disrupting the layout:
<p>Visit our website at: https://www.example.com/<wbr>categories/<wbr>products/<wbr>item12345</p>
Rendered Output:
Visit our website at: https://www.example.com/
The <wbr> tag does not introduce any visible changes unless a line break occurs. It does not add hyphens or other characters; it simply indicates where the browser can break the word if necessary. To control hyphenation, consider using the CSS hyphens property in conjunction with the <wbr> tag.
The <wbr> tag is generally ignored by screen readers and does not affect the pronunciation or interpretation of the text. It serves purely as a visual aid for managing text layout.
Using the <wbr> tag does not impact SEO, as it does not alter the content or meaning of the text. It is a presentational tool to improve the readability and layout of text on the page.
The <wbr> tag is a useful HTML5 element for controlling word break opportunities within text, helping to prevent layout issues caused by long words or URLs. By strategically placing <wbr> tags, developers can enhance the readability and responsiveness of their web pages without altering the content's meaning.
HTML5 Tags Types of HTML tags