I'm dynamically adding Content Blocks with AMPScript depending on certain pieces of data. Each Content Block ideally would be a TD of a TABLE. It looks like SFMC automatically wraps each Content Block with a DIV with an attribute of DATA-MARKER="wrapper". Is there a way to have SFMC only render the code I write?

Then end result would be dynamically generating a table where each piece of content is a TD of the TABLE.

  • Are you using Freeform or HTML-only content areas? – Adam Spriggs Sep 20 '16 at 0:36
  • I've certainly never seen this behavior. Can you post an example of your code? – Eliot Harper Sep 20 '16 at 11:00
  • @AdamSpriggs I've tried both Freeform and HTML. In Classic I remember Freeform wrapping the Content Area, but I thought HTML did not. In Content Builder I am seeing a wrapping DIV for both. – victorcorey Sep 20 '16 at 15:46
  • @AdamSpriggs In Classic I remember the same. Freeform wrapped and HTML not wrapped. I guess it changed. :-( – victorcorey Sep 27 '16 at 19:03

The DIV warpper is usually applied when you use any block other than the HTML block. This is true in both Classic and Content Builder/Email Studio. This is designed to help retain all styling, etc with the blocks inside of their 'out of the box' templates. (I have had many conversations about this with SFMC support previously and this is the answer they provided...)

The div wrapper shouldn't greatly affect your code, but if it does then you will need to exclusively use the HTML block only. This block should have no wrapper and allow you to have full control of the block.

Another solution that will guarantee no extra code, but is much less user friendly and more difficult to edit is to build the custom sections in a data extension. You would write the HTML and use a data extension to store it - will need to include a unique key assigned to each to allow for easy lookup. You then call it out via AMPScript/SSJS.

EDIT After some research, I have found that my Email Studio Content Builder actually wraps my content blocks in a table, regardless of content block type. I am not sure when this was changed, nor really why it was changed but I wanted to provide what should be a duct-tape band-aid for this issue:


<table cellpadding="0" cellspacing="0" width="100%" class="stylingblock-content-wrapper" style="; width: 100%;">
<td class="camarker-inner stylingblock-content-wrapper" align="left">MY CONTENT</td>

Write MSO conditional code around the inline content blocks in your template (to allow Outlook to correctly display):

<!--[if (gte mso 9) | (IE)]><table width="620" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td valign="top" align="center" width="305"><![endif]-->
<div style="display:inline-block; width:49%;">YOUR LEFT CONTENT BLOCK HERE</div>
<!--[if (gte mso 9) | (IE)]></td><td align="center" width="305"><![endif]-->
<div style="display:inline-block; width:49%;">YOUR RIGHT CONTENT BLOCK HERE</div>
<!--[if (gte mso 9) | (IE)]></td></tr></table><![endif]-->

and then add a style in the head (as gmail is going to accept styles in the near future, this should be pretty much universal) something like below:

.stylingblock-content-wrapper {display:inline-block !important;}

This style is likely to be unnecessary due to the div and MSO table, but is nice to have just in case. You will likely need to adjust this some to fit your exact need, but should help get you to a final solution.

  • I thought that was the case with HTML Blocks, but I am seeing a wrapping DIV around the HTML Content Block as well. The problem I have is the Content Block is getting iterated over and I would like them to not be block level but inline. – victorcorey Sep 20 '16 at 15:50
  • 1
    well, I am not sure what has changed then, but what I would do is write MSO conditional code around the blocks in your template you want inline (to allow Outlook to correctly display) and then add a style in the head (as gmail is going to accept styles in the near future, this should be pretty much universal) something like below: div .SFMC { display:inline-block !important} – Gortonington Sep 20 '16 at 16:16

All blocks get wrapped in a table in Content Builder. For the use case you're describing where you don't want that wrapper, use a Code Snippet instead. This feature was introduced in the October 2016 release.

To create a snippet, go to Create -> Code Snippet in Content Builder. You build it just like a block, and you can insert a snippet into your HTML one of 3 ways:

  1. Via the Code Snippets toolbar selector in the HTML editor
  2. By typing the CustomerKey value for that snippet and pressing Tab
  3. Using any of the "ContentBlockBy" AMPScript functions.

In all cases, only your HTML defined in the snippet will be inserted, with no wrapper.

  • I'm using code snippets for a dynamic sender profile and calling them in using the ContentBlockByID() function. The code snippet has no HTML yet the content is being wrapped with a bunch of HTML comment tags. E.G. "<!----><!----><!----><!----> <!----><!----><!----> XXXX<!----> <!---->" – Daniel Jun 30 '18 at 14:36
  • That's a different issue all together. The comments are there to support the Google 360 integration; they should only be showing up in email bodies, but they're showing up everywhere instead. A fix is coming shortly. – Don Owens Jul 2 '18 at 11:20
  • Thanks @Don Owens - does shortly mean later today? Week? Month? ;) – Daniel Jul 2 '18 at 20:55
  • @Daniel Sorry - I was out of the office last week and just now saw your question. This should be in place now. – Don Owens Jul 10 '18 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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