7

I'm new to mjml and I'm trying to find out if there is a way to make <mj-text> elements to display inline-block without using <mj-style> or inline css.

I have an <mj-text> which renders dynamically-generated text - so I have no way to foresee its width. I would like this container's background to end where the text ends and not fill the entire page's width (like block elements do).

Here is and example of the template I'm trying to render:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text align="left" container-background-color="#c3e16d" color="#60b7f1" font-size="14px">
          <span>Dynamically Generated Text</span>
        </mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

After some searching I did manage to get it to work using an <mj-style> block - but what I'm trying to figure out if there is a more proper way to do it using the mjml api.

itaydafna
  • 1,968
  • 1
  • 13
  • 26

1 Answers1

7

The way you did it is perfectly fine. You could also simply use inline styles on the span tag, like this.

As the span tag is made for this type of need and does it well already, we didn't implement anything to replace that in MJML.

Nicolas Garnier
  • 370
  • 1
  • 10