简体   繁体   English

如何防止html链接中的换行符?

[英]How to prevent a line break in a html link?

也就是说,整个html链接必须在第1行或第2行,而不是在两行中。

According to this post : 根据这篇文章

NOBR Tag not suppored by W3C. NOBR标签不受W3C的支持。 So use the alternative tag for it. 因此,请使用替代标记。 Instead of giving NOBR tag give the tag as style="white-space: nowrap". 而不是给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; }

Using CSS: 使用CSS:

a {
    white-space: nowrap;
}

This will prevent line breaks in any A tags. 这样可以防止任何A标记中的换行符。

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规范并未正式支持。

none of that worked for me. 这些都不适合我。 I used a display:inline style and solved it 我使用了一个显示:内联样式并解决了它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM