<wbr> - HTML: HyperText Markup Language 编辑
The HTML <wbr>
element represents a word break opportunity—a position within text where the browser may optionally break a line, though its line-breaking rules would not otherwise create a break at that location.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.Content categories | Flow content, phrasing content. |
---|---|
Permitted content | Empty |
Tag omission | It is an empty element; it must have a start tag, but must not have an end tag. |
Permitted parents | Any element that accepts phrasing content. |
Implicit ARIA role | No corresponding role |
Permitted ARIA roles | Any |
DOM interface | HTMLElement |
Attributes
This element only includes the global attributes.
Notes
On UTF-8 encoded pages, <wbr>
behaves like the U+200B
ZERO-WIDTH SPACE
code point. In particular, it behaves like a Unicode bidi BN code point, meaning it has no effect on bidi-ordering: <div dir=rtl>123,<wbr>456</div>
displays, when not broken on two lines, 123,456
and not 456,123
.
For the same reason, the <wbr>
element does not introduce a hyphen at the line break point. To make a hyphen appear only at the end of a line, use the soft hyphen character entity (­
) instead.
This element was first implemented in Internet Explorer 5.5 and was officially defined in HTML5.
Example
The Yahoo Style Guide recommends breaking a URL before punctuation, to avoid leaving a punctuation mark at the end of the line, which the reader might mistake for the end of the URL.
<p>http://this<wbr>.is<wbr>.a<wbr>.really<wbr>.long<wbr>.example<wbr>.com/With<wbr>/deeper<wbr>/level<wbr>/pages<wbr>/deeper<wbr>/level<wbr>/pages<wbr>/deeper<wbr>/level<wbr>/pages<wbr>/deeper<wbr>/level<wbr>/pages<wbr>/deeper<wbr>/level<wbr>/pages</p>
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<wbr>' in that specification. | Living Standard | |
HTML5 The definition of '<wbr>' in that specification. | Recommendation |
Browser compatibility
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.See also
overflow-wrap
word-break
hyphens
- The
<br>
element
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论