Nerdrium Home

Macintosh

Linux

Web Design

Case Mods

Gardening

Photography

Recipes

 

My Blog

 

Facebook

Twitter

Non-Breaking Hyphen

by Michael Greifenkamp (March 28th, 2007)

About once a year I need to use a non-breaking hyphen in my html mark-up. It usually happens when I want to force a range of numbers in a table cell not to split onto two lines.

And the magic character is?

‑

I've tested it in Safari, Firefox (for Mac, for Linux, and for Windows), and Internet Explorer (for Mac and for Windows, although you shouldn't be using IE, you should be using Firefox).

Note: There's a much better way to keep lines from breaking than using a non-breaking hyphen. Use CSS instead:

<html>
<head>
<style type="text/css">
p.nobreak { white-space:nowrap;}
</style>
</head>
<body>
<p class="nobreak">This won't break--honest</p>
</body>
</html>

Drop me a line if you have any comments or questions.

--Michael