Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent line breaks between words and punctuation in CSS or jQuery

I have some text in a paragraph. My problem is that when punctuation is at the end of a word, it can sometimes be wrapped to the next line. Like this:

This is the text
, This is a new line

Can I resolve this with CSS or jQuery?

like image 807
tommywang Avatar asked Mar 26 '13 12:03

tommywang


1 Answers

If you don't put a space between the word and the punctuation, and that it is wrapped anyway, you can use the white-space: nowrap; css instruction. Otherwise, if you need a space between the word and the punctuation, like before a ?, use the non-breaking space code. You can have it by typing alt + 0160 on your keyboard if you're using Windows. For more keyboard methods, read this.

I hope it will help.

like image 86
Djouuuuh Avatar answered Sep 18 '22 23:09

Djouuuuh