In the webform-mail.tpl.php template, it outputs the main form data using:


I am using the html format (using mime-mail) and this outputs to the email html in the form:

<div><label>Name</label>Name value</div>

Is there a way I can customise the output so that it doesn't use the label field and uses a <p> tag instead?

The problem with the <label> tag is that I cannot style it in Microsoft Outlook as it ignores all styling for this tag, and the email is quite difficult to read/understand.

1 Answer 1


I managed to find the answer from an identical question at How to use [submission:values] in Email template in Webforms.

Using the webform-submissions.tpl.php template I changed the output structure from:

<div><label>Name</label>Name value</div>


<div><p class="label">Name</p><p class="value">Name Value</p></div>

Using the code below:

if ($format == 'html') {
    $output = drupal_render_children($renderable);
    $output = preg_replace('/<label.*?>/', '<p class="label">', $output);
    $output = str_replace(' </label>', ':</p><p class="value">', $output);
    $output = str_replace('</div>', '</p></div>', $output);
    print $output;

Now the styling in my Outlook emails look much better :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.