vs white-space:nowrap

核能气质少年 提交于 2019-12-04 21:02:11

问题


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 style my element with white-space:nowrap? Are there any 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.



来源:https://stackoverflow.com/questions/15411260/nbsp-vs-white-spacenowrap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!