Can I break the line at special characters using CSS?

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>


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.

Tags:

Css