Answers.Body: <p>I've been using something like this by adding HTML to the CiviMail Header and Footer options. </p>
  
  <ul>
  <li><a href="https://gist.github.com/danaskallman/57616e7d17cc4c4f5050" rel="nofollow">https://gist.github.com/danaskallman/57616e7d17cc4c4f5050</a></li>
  <li><a href="https://gist.github.com/danaskallman/1a40f03900a631c6389b" rel="nofollow">https://gist.github.com/danaskallman/1a40f03900a631c6389b</a></li>
  </ul>
  
  <p>It works nicely, wraps around the content area so that no HTML has to go in that area if not wanted to do so. Works best with Single column newsletters, which I believe work best on mobile anyway. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-12T19:11:52.997Z
Answers.Text: I see - so you have no /head tag at all.  Then you open the /body tag in the header.  I presume you close it in the content somewhere ? will play with this a bit.
Answers.UserDisplayName: Sonicthoughts
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-13T14:06:40.620Z
Answers.Text: @Sonicthoughts, I think the `body` tag should be closed at the bottom of the footer code.
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-12T16:52:35.503Z
Answers.LastActivityDate: 2015-08-12T16:52:35.503Z
Answers.UserDisplayName: Dana
Answers.Body: <p>I've created a header and footer that "wraps" the body HTML similar to what @Dana has done, but ours has a  tag that includes a link to a CSS file. We then use an extension which converts all styling to inline CSS as the email sends. It's worked really well for us and has allowed for some decent flexibility in email layout and style.</p>
  
  <p><a href="https://github.com/eileenmcnaughton/nz.co.fuzion.cssinline" rel="nofollow">https://github.com/eileenmcnaughton/nz.co.fuzion.cssinline</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-08T12:50:28.947Z
Answers.Text: Do you think it would be useful to develop an extension to add an header and footer tokens for transactional emails? Do you know if anyone has already done so?
Answers.UserDisplayName: masetto
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-14T18:13:24.373Z
Answers.Text: clever way to maintain styles!  I noticed that extension has not been updated to 4.6 - are you using 4.6 or 4.4? It sounds like manually keeping opening the body tags header and closing in the footer is the way to go.
Answers.UserDisplayName: Sonicthoughts
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-14T18:21:44.650Z
Answers.Text: Also, we are using mandrill and I just noticed you can do inline css by changing the header: http://bit.ly/1WpDjCw but that may slow down for each mail.  will check it out - just concerned about maintaining cssinliner.
Answers.UserDisplayName: Sonicthoughts
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-14T18:58:00.753Z
Answers.Text: We just updated to 4.6 and so far the cssinline extension hasn't been affected. If you aren't using the Mandrill extension you might take a look at that as well, I believe the newer version of that support bulk as well as transactional emails. We use SendGrid and had an extension built to capture tracking data. It's been recently updated to be compatible with Civi 4.6 but I haven't submitted the new version to the Extensions directory, the Civi 4.4 version is here: https://github.com/fulltrucker/com.imba.sendgrid
Answers.UserDisplayName: Evan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-14T19:01:09.830Z
Answers.Text: Also, the maintainer of cssinline is highly active in the Civi community, my sense it will be supported for a while. If Mandrill has functionality to do that, it's worth a shot. MailChimp does an amazing job of inlining CSS when you use that service, I would expect Mandrill to be on par.
Answers.UserDisplayName: Evan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-14T18:06:25.127Z
Answers.LastActivityDate: 2015-08-14T18:06:25.127Z
Answers.UserDisplayName: Evan
Answers.Body: <p>I doubt this is "best practice" but thanks for the hint from @Dana I used all css styles and meta in the   tag and closed it.</p>
  
  <p>I  kept the   open in the header.  Made sure the template HTML does not have any  or  tag anywhere.  Then added the closing  and  in the footer.</p>
  
  <p>This is definitely hackish but seems to work.  I don't know if the html parsing is supposed to do this but a nice feature might be to have an option for each of these (header/body/footer) to strip the head, html and body tags when creating a template.  but love to hear a better way to do this!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-12T21:39:03.690Z
Answers.LastActivityDate: 2015-08-12T21:39:03.690Z
Answers.UserDisplayName: Sonicthoughts
Body: <p>I've seen several questions about how to use civimail header/footer but can't find a best practice for coding.</p>
  
  <p>I know email coding can be hairy especially since clients handle things differently and there is no "standard."  I've done some basic homework. CSS styles are typically inline.  There is usually the standard HTML document structure with DOCTYPE, head, and title tags.  The styles are placed in the /head section.  The "problem" is that (as I understand it) HTML requires only one /head /body tag.  So if we want HTML in the Header / Body / Footer how should it be coded?  Is there a post-process to strip or merge tags?  Sorry if this is naive, this my first foray into email coding.</p>
  
  <p>Note: I tried to put all the styles in the template header but they were ignored in the body (probably a scope issue.)</p>
  
  <p>I see a related question: <a href="https://civicrm.stackexchange.com/questions/4528/how-can-i-use-html-head-body-tags-in-a-mailing">How can I use &lt;html&gt;, &lt;head&gt;, &lt;body&gt; tags in a mailing?</a> however, I'm not using CKeditor and still have issues.</p>
  
  <p>Do we need some sort of Wrapper Template defined?</p>
  
Tags: <civimail><email><message-templates>
Title: Coding of civimail header body and footer - best practice
ThreadText: # Coding of civimail header body and footer - best practice
  
  (Asked by: username_0 on 2015-08-12)
  
  I've seen several questions about how to use civimail header/footer but can't find a best practice for coding.
  
  I know email coding can be hairy especially since clients handle things differently and there is no "standard." I've done some basic homework. CSS styles are typically inline. There is usually the standard HTML document structure with DOCTYPE, head, and title tags. The styles are placed in the /head section. The "problem" is that (as I understand it) HTML requires only one /head /body tag. So if we want HTML in the Header / Body / Footer how should it be coded? Is there a post-process to strip or merge tags? Sorry if this is naive, this my first foray into email coding.
  
  Note: I tried to put all the styles in the template header but they were ignored in the body (probably a scope issue.)
  
  I see a related question: [How can I use , ,  tags in a mailing?](https://civicrm.stackexchange.com/questions/4528/how-can-i-use-html-head-body-tags-in-a-mailing) however, I'm not using CKeditor and still have issues.
  
  Do we need some sort of Wrapper Template defined?
  
  **Tags:** civimail, email, message-templates
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2015-08-12. Score: 3
  
  I've been using something like this by adding HTML to the CiviMail Header and Footer options.
  
  * <https://gist.github.com/danaskallman/57616e7d17cc4c4f5050>
  * <https://gist.github.com/danaskallman/1a40f03900a631c6389b>
  
  It works nicely, wraps around the content area so that no HTML has to go in that area if not wanted to do so. Works best with Single column newsletters, which I believe work best on mobile anyway.
  
  > **Comments:**
  > **username_0**: I see - so you have no /head tag at all.  Then you open the /body tag in the header.  I presume you close it in the content somewhere ? will play with this a bit.  
  > **username_2**: @username_0, I think the `body` tag should be closed at the bottom of the footer code.  
  
  ---
  
  ### Answer by username_3 on 2015-08-14. Score: 1
  
  I've created a header and footer that "wraps" the body HTML similar to what @username_1 has done, but ours has a tag that includes a link to a CSS file. We then use an extension which converts all styling to inline CSS as the email sends. It's worked really well for us and has allowed for some decent flexibility in email layout and style.
  
  <https://github.com/eileenmcnaughton/nz.co.fuzion.cssinline>
  
  > **Comments:**
  > **username_0**: clever way to maintain styles!  I noticed that extension has not been updated to 4.6 - are you using 4.6 or 4.4? It sounds like manually keeping opening the body tags header and closing in the footer is the way to go.  
  > **username_0**: Also, we are using mandrill and I just noticed you can do inline css by changing the header: http://bit.ly/1WpDjCw but that may slow down for each mail.  will check it out - just concerned about maintaining cssinliner.  
  > **username_3**: We just updated to 4.6 and so far the cssinline extension hasn't been affected. If you aren't using the Mandrill extension you might take a look at that as well, I believe the newer version of that support bulk as well as transactional emails. We use SendGrid and had an extension built to capture tracking data. It's been recently updated to be compatible with Civi 4.6 but I haven't submitted the new version to the Extensions directory, the Civi 4.4 version is here: https://github.com/fulltrucker/com.imba.sendgrid  
  > **username_3**: Also, the maintainer of cssinline is highly active in the Civi community, my sense it will be supported for a while. If Mandrill has functionality to do that, it's worth a shot. MailChimp does an amazing job of inlining CSS when you use that service, I would expect Mandrill to be on par.  
  > **username_4**: Do you think it would be useful to develop an extension to add an header and footer tokens for transactional emails? Do you know if anyone has already done so?  
  
  ---
  
  ### Answer by username_0 on 2015-08-12. Score: 0
  
  I doubt this is "best practice" but thanks for the hint from @username_1 I used all css styles and meta in the tag and closed it.
  
  I kept the open in the header. Made sure the template HTML does not have any or tag anywhere. Then added the closing and in the footer.
  
  This is definitely hackish but seems to work. I don't know if the html parsing is supposed to do this but a nice feature might be to have an option for each of these (header/body/footer) to strip the head, html and body tags when creating a template. but love to hear a better way to do this!
  
  
  ---
  
  