HTML <wbr> 元素  — 一个文本中的位置,其中浏览器可以选择来换行,虽然它的换行规则可能不会在这里换行。

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.
Permitted ARIA roles Any
DOM interface HTMLElement

属性

这个元素仅仅包含 全局属性

Notes

在 UTF-8 编码的页面中, <wbr> 表现为 U+200B ZERO-WIDTH SPACE (零宽空格)代码点。特别是,它表现为 Unicode bidi BN 代码点,也就是说,它对 bidi-ordering 没有影响:<div dir=rtl>123,<wbr>456</div> 展示 123,456 而不是 456,123,当不拆成的两行时候。

出于相同原因, <wbr>元素不会在换行的地方引入连字符。为了使连字符仅仅在行尾出现,使用连字符软实体 (&shy;) 来代替。

这个元素首先在 Internet Explorer 5.5 中实现,并且在 HTML5 中官方定义。

示例

Yahoo 代码规范 推荐 在标点之前为 URL 换行,以便避免将标点符号留在行尾,这会让读者将 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>

规范

Specification Status Comment
HTML Living Standard
<wbr>
Living Standard  
HTML5
<wbr>
Recommendation  

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 1Edge Full support YesFirefox Full support 1IE No support 5.5 — 7Opera Full support 11.6Safari Full support 4WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

文档标签和贡献者

此页面的贡献者: Ende93, wizardforcel
最后编辑者: Ende93,