Reputation: 115
I have a line for ex: "Break at Special Character;String Break;Example Break". I would like to break the line with respect to ";" using CSS.
Is there any possible way to do so. Please suggest
Upvotes: 11
Views: 15340
Reputation: 11270
You can use wbr elements to indicate where you want the text to break.
Upvotes: 0
Reputation: 1473
No, there is no ways to do so. If it would be possible to control by CSS, I think it would control wrapping with insufficient width of block. If you do not want add markup to text, you can programmatically add html newlines by using JavaScript (if there is a HTML-page) or any other one.
Upvotes: 2
Reputation: 201588
No, unfortunately CSS currently has no tools for specifying that line breaks should be allowed (or forced) after some character(s). You need to wrap characters or strings in elements and specify line breaking behavior for the elements.
The following example shows first how to force line breaks, then how to allow line breaks that would not otherwise appear. This uses generated content; there are other techniques too.
.br::after { content: "\a"; white-space: pre; } /* line break */
.bro::after { content: "\200b"; } /* zero-width space */
<p>Break at Special Character<span class=br>;</span>String Break<span class=br>;</span>Example Break</p>
<p style="width: 10em">Break at Special Character<span class=bro>;</span>String Break<span class=bro>;</span>Example Break</p>
Upvotes: 2
Reputation: 19835
There are ways to do this. Both will not force the line break:
Upvotes: 2