Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

  vs white-space:nowrap

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?

like image 309
oscilatingcretin Avatar asked Mar 14 '13 13:03

oscilatingcretin


1 Answers

There are cases where nonbreaking space cannot help:

  • the word contains a hyphen (e.g. web-developer);
  • hyphens: auto is used for the container element to do 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 solely work when styles are enabled.

like image 130
Marat Tanalin Avatar answered Sep 28 '22 06:09

Marat Tanalin