HTML <wbr> Tag

The <wbr> tag is used to instruct the browser, where in the text a line-break could be added. Unlike the <br> tag, which oblige the browser to insert a line-break, when <wbr> is used the browser first analyze its content, and then insert a line-break if necessary (too long word or URL address).

In case you do not use the <wbr> tag, long words could either wrap in a wrong place (making it difficult to read), or not wrap at all - pushing the page layout to the side.

The <wbr> tag is one of the HTML5 elements.

A hyphen at the line breakpoint is not introduced by the <wbr> element. If you want a hyphen to occur only at the end of a line, use &shy; (soft hyphen character entity).

You may not use this element frequently. But if you need it, the <wbr> will be really useful. Let’s look through the example below, where we have a file path.

<p>You can find the file by going
  C:\user\docs\Letter.txt
</p>

As you can see there isn’t any line-break opportunity, and the whole file path went to the next line. If you add <wbr> elements, the file path will break properly, while rendering that paragraph.

<p>You can find the file by going C:<wbr>\user<wbr>\docs<wbr>\Files<wbr>\Letter.txt</p>

Syntax

The <wbr> tag is empty, which means that the closing tag isn’t required. But in XHTML, the (<wbr>) tag must be closed (<wbr/>).

Example of the HTML <wbr> tag:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <p>Example of a long string of text without wbr.</p>
    <p>This is the longest word you can ever meet in the English language pneumonoultramicroscopicsilicovolcanoconiosis</p>
    <p>Example of a long string of text with wbr.</p>
    <p>This is the longest word you can ever meet in the English language pneumono<wbr>ultra<wbr>micro<wbr>scopic<wbr>silico<wbr>volcano<wbr>coniosis</p>
    </p>
  </body>
</html>

Result

wbr tag example

Attributes

The <wbr> tag supports the Global attributes and the Event Attributes.

Browser support

chrome firefox safari opera
1+ 3+ 4+ 11.7+

Practice Your Knowledge

What is the primary use of the <wbr> tag in HTML?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?