How do I retain the formatting of the description field in a notification template?

August 25, 2011 Posted by Anders Asp

I’ve seen this question far too many times now, it’s time to write a blogpost about it.

The short answer is <pre>, the long is described below. 🙂

If you need more information on Notification templates in general, take a look at Travis post:

Problem description

Take a look at this incident:

As you can see it has a description that spans over several lines.

If we would like to send a notification to our end user upon the creation of the incident using the notification template below…

… that e-mail would look like this:

Allright, that works, but it’s a bit hard to read and looks a little boring, don’t you think?

Let’s add some formatting to our template, and as you might know, that is done by applying HTML to the notification template.

This is basically the same notification template, but with bold headlines:

But take a look at the e-mail now:

What happend to the formatting of the description field? Well since we are sending the e-mail in HTML now the formatting is stripped; cause a line break should be written as <br /> and not with the enter key on the keyboard.


The solution to this is rather simple and reads <pre>.

<pre> is an HTML tag and the definition of it is:

“The <pre> tag defines preformatted text. Text in a pre element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks.”

So lets edit our notification template and add the pre tag:

And now lets take a look at the e-mail:

The line-breaks (and all extra spaces if we had any) are retained, great!
If you want to change the formatting in any other way, you could always add some inline CSS to the <pre> tag, like this:

And that would result in an e-mail that looks like this:


7 Responses to How do I retain the formatting of the description field in a notification template?

  1. Fadi Khoury says:

    Thanks Man. I have worked with html for ages and i didn’t know about that tag till now.
    Ur a genius

  2. Ronald Freier says:

    Hi Anders,

    you are my hero of the day.
    Sometimes it can be so simple.


  3. Nick says:

    my haedach are gone now…
    Great post!

  4. Der Artikel ist wirklich gut. Das Thema hat mich schon länger interessiert und ich konnte hier noch einiges ergänzendes finden. Ich
    kann es kaum erwarten, weitere Neuigkeiten zu lesen. Danke und Grüße aus
    Heidelberg Marco Feindler

  5. zoloft says:

    buying zoloft in dublin zoloft generic; i want to order
    zoloft online
    sertraline high sertraline 50 mg zoloft online walgreens

  6. site link says:

    Normally I don’t read post on blogs, however I wish to say that this write-up very forced me to try and do so!
    Your writing taste has been amazed me. Thank you, quite nice post.

  7. Every weekend i used to pay a quick visit this site, for the reason that i want enjoyment, for the reason that this this web site conations genuinely good funny stuff too.

Leave a Reply

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