Wrap text on line break with CSS

If you have a block of text and you want to display it with linebreaks, such as my public PGP Key, you can add the following style to that paragraph:

white-space: pre-line;

So this:

Becomes this:

You might have to add some browser specific prefixes:

white-space: -moz-pre-line; /* Firefox */
white-space: -pre-line; /* ancient Opera */
white-space: -o-pre-line; /* newer Opera */
white-space: pre-line; /* Chrome; W3C standard */
word-wrap: break-word; /* IE */


Author Bio

Thank you for your interest in my blog! On this miniblog, I write mostly short (technical) blog posts that might interest other people. Read more about me or feel free to contact me.


Leave a Reply

Your email address will not be published. Required fields are marked *