I will admit that I have a habit of using
between words when I don't want them to break (table headers for example). Should I really be styling my element with white-space:nowrap
? Are there advantages/disadvantages to either if the only thing I am looking to do is keep words from wrapping?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There are cases where nonbreaking space cannot help:
- word contains hyphen (e.g. web-developer);
hyphens: auto
is used for element containing text to make hyphenation automatically.
In these cases, white-space: nowrap
is useful. Also, nonbreaking space works regardless of whether styles are applied to document while CSS rules work solely when styles are enabled.