Non-breaking Hyphen

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?

& #8209;

This is cross-browser compatible.

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>This won’t break–honest</p>
</body>
</html>

Advertisements
Published in: on July 14, 2010 at 6:04 pm  Leave a Comment  

The URI to TrackBack this entry is: https://blackbeltreview.wordpress.com/2010/07/14/non-breaking-hyphen/trackback/

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: