Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 596 Bytes

preserve-whitespace-in-css.md

File metadata and controls

22 lines (16 loc) · 596 Bytes

Preserve Whitespace in CSS

Let's say you have a string evaluated into a HTML template that contains newlines, like "getting\n\things\ndone" and you want those newlines to be reflected in the presentation. Like this:

getting
things
done

We can solve this with the following CSS on the string's containing element:

white-space: pre-wrap;

With pre-wrap, "[s]equences of white space are preserved. Lines are broken at newline characters, at [breaks] and as necessary to fill line boxes."

white-space docs