Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML no line break at hyphens

Tags:

html

So I have the text e-commerce and I don't want the line to wrap at the dash.
How would I restrict wrapping for that text line?

like image 703
Kirk Strobeck Avatar asked Aug 28 '11 04:08

Kirk Strobeck


People also ask

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.

How do you write without line break in HTML?

There are several ways to prevent line breaks in content. Using   is one way, and works fine between words, but using it between an empty element and some text does not have a well-defined effect. The same would apply to the more logical and more accessible approach where you use an image for an icon.

How do you hyphenate text in HTML?

In HTML, use ­ to insert a soft hyphen.


2 Answers

You could use CSS: white-space: nowrap;.

Example: Wrap the text in a span with that CSS declaration.

<span style="white-space: nowrap;">e-commerce</span>

like image 145
Paul Sham Avatar answered Oct 02 '22 06:10

Paul Sham


Use the non-breaking hyphen: &#8209;

like image 26
Michael Lorton Avatar answered Oct 02 '22 07:10

Michael Lorton