Preventing line breaks in HTML

6

Is there any way to prevent a line break in HTML? For example, on one of my web pages the browser put a break after the comma in the number 43,560. I could remove the comma, but that makes the number harder to read.

I seem to remember old-style HTML has a way to prevent line breaks but it isn't universally supported and isn't legal in stricter varieties like XHTML.

John D. Cook

Posted 2009-11-20T16:21:38.027

Reputation: 605

Question was closed 2009-11-20T18:02:14.517

1belongs to stack overflow ! – joe – 2009-11-20T16:22:39.117

1or belongs in doctype – ricbax – 2009-11-20T16:44:01.663

The tag you were looking for was the <NOBR> tag, but you should use Johannes's answer below. – Travis – 2009-11-20T17:25:58.350

http://doctype.com/ – Kevin Panko – 2009-11-20T17:26:43.373

Answers

20

You can use styles to ensure that the browser won't break lines there. CSS has a white-space property which does that. So

<span style="white-space: nowrap;">43,560</span>

should work.

If you need this more often, you should probably create a CSS class for that, though.

Joey

Posted 2009-11-20T16:21:38.027

Reputation: 36 381