Auralinna.blogTero Auralinna's blog about intriguing world of web development. Tweaking pixels since the '90s.

I'm a Full Stackish web developer with a strong passion for a beautiful and solid front end. I have mainly focused on front-end development, responsive web design, Content Management Systems, modern web frameworks, DevOps and back-end coding with PHP, Node.js and Java.

Wrapping newlines via CSS

30.11.2017

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.

Latest blog posts

Latest CodePens

View all CodePens