Within a div
of set width, a string is being bound to it. This string could be short or long.
I would like for the string to break with a hyphen inserted on each line except for the last one.
For example: If the string is "misconception" and it breaks at misc, it should look like this ->
misc-
once-
ptio-
n
instead of this ->
misc
once
ptio
n
Please note: I have attempted using the following CSS:
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
However, the issue lies in the fact that hyphens
only work with dictionary words. In my scenario, the string can vary from anything such as names to random strings, hence hyphens
are not effective in my case.
You can view the demo here.