<wbr>

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

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

Attributes

Attributes

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



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部