Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS end line on letter

Tags:

css

I'm trying to get the text in a div with a fixed width to break on a letter instead of a word. I cant really think of a way to explain it so I made a little example. Any help would be greatly appreciated.

What happens now.

|Hello   |
|World!  |

What I want:

|Hello Wo|
|rld!    |
like image 316
Lienau Avatar asked Nov 17 '10 05:11

Lienau


People also ask

How do you type the last line in CSS?

The text-align-last property in CSS is used to set the last line of the paragraph just before the line break. The line break may be due to the natural ending of a paragraph, or it may be due to the use of <br> tag.

How do you break a single word in CSS?

The word-break property in CSS is used to specify how a word should be broken or split when reaching the end of a line. The word-wrap property is used to split/break long words and wrap them into the next line. word-break: break-all; It is used to break the words at any character to prevent overflow.

What is word-break in CSS?

The word-break CSS property sets whether line breaks appear wherever the text would otherwise overflow its content box.

What is text-align-last?

The text-align-last CSS property sets how the last line of a block or a line, right before a forced line break, is aligned.


1 Answers

word-wrap: break-word;

As per the CSS W3 Spec:

An unbreakable "word" may be broken at an arbitrary point if there are no otherwise-acceptable break points in the line. Shaping characters are still shaped as if the word were not broken, and grapheme clusters must together stay as one unit.

like image 155
Russell Dias Avatar answered Sep 23 '22 03:09

Russell Dias