14

I have a bunch of links in a div. Some have format "some-name". those with hyphen will split and wrap. I would like it to start a new line. How to do this please?

zsharp
  • 13,656
  • 29
  • 86
  • 152

5 Answers5

22

You can use a non-breaking hyphen character, ‑

Ben James
  • 121,135
  • 26
  • 193
  • 155
13

You can use the CSS attribute: white-space:nowrap; But note that it is not working all the time on some browser.

The other option is to wrap your link into a <pre> element but this approach can have some side effects as well.

6
<span style="white-space: nowrap;">some-name</span>
Chris Fulstow
  • 41,170
  • 10
  • 86
  • 110
0

turn off formatting with

<pre>...</pre>
Doug Neiner
  • 65,509
  • 13
  • 109
  • 118
dar7yl
  • 3,727
  • 25
  • 20
-1

You can also do this:

<nobr>Table-text</nobr>

Reference:

How to prevent line break at hyphens on all browsers

Community
  • 1
  • 1
cssyphus
  • 37,875
  • 18
  • 96
  • 111
  • 1
    Probably because it's not good practice to recommend [Non-Standard and Obsolete html tags](http://www.w3.org/TR/html5/obsolete.html#obsolete). Per the World Wide Web Consortium - `Elements in the following list are entirely obsolete, and must not be used by authors: ... nobr ...` – Erik Philips Mar 09 '15 at 04:47