Skip to content

Wrapping newlines via CSS

twitter logo github logo Originally published at on ・1 min read  

This is a simple tip how to wrap newlines without converting newlines to <br> tags. This is quite handy if you have a text without formatting and the only need is to wrap text paragraphs. You don't have to think about HTML sanitization or conversion.

.wrapped-text {
    white-space: pre-line;

Just trim newlines from the beginning and end of the text before rendering. Value pre-line doesn't render whitespaces in the middle of the text.

This blog post was originally published on

twitter logo DISCUSS
Classic DEV Post from Jun 15 '19

Know Not Only Your Weaknesses, But Strengths as Well

Most people want to develop self-awareness. Whether we are managers, entrepreneurs, or aspiring software engineers, the more knowledge we have of our strength and weaknesses, the easier life becomes.

Tero Auralinna profile image
Tweaking pixels since the '90s