Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dash that prevents line-break between both words

Tags:

html

Is there any way to have a dash ( - ) that wont break the word if it's ending a line? (Just like   prevents a line break between two words)

The problem that I currently have is a blog post (dynamic) that has the word X-Ray in it. Sadly, it falls on the end of a line so I get

Lorem ipsum dolor si amet X-
Ray

I would like to prevent that, and get a result like this

Lorem ipsum dolor si amet
X-Ray

I can't just <br /> everything, because depending on where you are on the website, it won't be stuck in that position everywhere.

like image 932
Fredy31 Avatar asked Sep 05 '12 15:09

Fredy31


People also ask

What is it called when a word is split between two lines?

Hyphenation (properly called word division) is breaking long words between lines. The purpose of hyphenation is to reduce the white space between words.

How do you not break a line with a hyphen?

The answer to this dilemma is to use non-breaking hyphens instead of regular dashes when you don't want Word to break a line at the hyphen. To do this, hold down the Ctrl and Shift keys as you type the dash (this is the same as typing Ctrl and an underscore). Word will then not break the line at that point.

Do you hyphenate do not break?

The answer to this dilemma is to use non-breaking hyphens instead of regular dashes when you don't want Word to break a line at the hyphen. To do this, hold down the Ctrl and Shift keys as you type the dash (this is the same as typing Ctrl and an underscore). Word will then not break the line at that point.

What is hyphenation in word?

Hyphenation is the use of a hyphen to break up a word when it reaches the edge of a document or container. The picture is an example of hyphenation. As shown in the picture, the word "service" is hyphenated as "ser-vice" because it's continued to the next line.


2 Answers

Try a non-breaking hyphen, &#8209;

Info at http://www.fileformat.info/info/unicode/char/2011/index.htm

like image 200
Scott Brown Avatar answered Sep 28 '22 00:09

Scott Brown


You can use the Unicode Character 'NON-BREAKING HYPHEN' (U+2011).

HTML Entity (decimal)   &#8209;
HTML Entity (hex)   &#x2011;
How to type in Microsoft Windows    Alt +2011
UTF-8 (hex) 0xE2 0x80 0x91 (e28091)
UTF-8 (binary)  11100010:10000000:10010001
UTF-16 (hex)    0x2011 (2011)
UTF-16 (decimal)    8,209
UTF-32 (hex)    0x00002011 (2011)
UTF-32 (decimal)    8,209
C/C++/Java source code  "\u2011"
Python source code  u"\u2011"
like image 36
kba Avatar answered Sep 28 '22 00:09

kba