Html 如何防止html链接中的换行符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2811056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to prevent a line break in a html link?
提问by lovespring
that is, a whole html link, must be in line1 or line 2. not in two lines.
也就是说,一个完整的 html 链接,必须在第 1 行或第 2 行。而不是在两行。
回答by Justin Ethier
According to this post:
根据这篇文章:
NOBR Tag not suppored by W3C. So use the alternative tag for it. Instead of giving NOBR tag give the tag as style="white-space: nowrap".
W3C 不支持 NOBR 标签。所以使用它的替代标签。不要给 NOBR 标签,而是将标签设为 style="white-space: nowrap"。
So that would mean you should say:
所以这意味着你应该说:
<a style="white-space: nowrap">link</a>
Or even better, put it inside your CSS:
或者更好,把它放在你的 CSS 中:
a { white-space: nowrap; }
回答by Jez
Using CSS:
使用 CSS:
a {
white-space: nowrap;
}
This will prevent line breaks in any A tags.
这将防止任何 A 标签中的换行符。
回答by Gabe
You can use <a><nobr>link</nobr></a>
您可以使用 <a><nobr>link</nobr></a>
Please note: This will work but is not officially supported by the W3C spec.
请注意:这会起作用,但不受 W3C 规范的正式支持。
回答by mark
none of that worked for me. I used a display:inline style and solved it
这些都不适合我。我使用了 display:inline 样式并解决了它