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:


4 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. Alma says:

    Good way of telling, and good paragraph to obtain information about my presentation topic, which i am going to deliver in institution of higher education.

Leave a Reply

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