2

how do I turn off the broken word in CSS? If the word contains the keyboard hyphenation, not the soft hyphen.

For example: One day talking to my first-year roommate

vkfjs
  • 101
  • 2
  • 11

2 Answers2

3

Use white-space: nowrap

p {
    white-space: nowrap;
}

If you want use nowrap on only part of a text, you can simply put that text in a span element and then apply nowrap to it.

Another much simpler way to prevent just your hyphenated string from wrapping is to replace the keyboard hyphen with ‑. This will render it as a non-breaking hyphen.

Updated example on jsFiddle

putipong
  • 350
  • 1
  • 9
1

Take a look at word-wrap

// Don't force hyphenate
p { word-wrap: normal; }

// Force words to hyphenate
p { word-wrap: break-word; }
DACrosby
  • 11,116
  • 3
  • 39
  • 51
  • I'm not quite sure, but I don't think the OP is talking about forcing or not forcing; he is talking about allowing or not allowing. –  Jan 20 '16 at 04:37