Mjml: mj-text is the equivalent of div / Which element for span ?

Created on 23 Mar 2017  路  6Comments  路  Source: mjmlio/mjml

I would like to have an inline equivalent of mj-text that allow to use
mj-class on inline element for example

<mj-text mj-class="text">
     <mj-text-inline mj-class="black"> My black</mj-text-inline > <mj-text-inline mj-class="blue">& blue title </mj-text-inline >
</mj-text>

The equivalent of

<div class="text>
    <span class="black"My Black</span><span class="blue">& blue title</span>
</div>

Of course I can add span inside mj-text, but the mj-class do not work on normal elements it seems

Most helpful comment

Hi @sinsunsan
I don't really understand the need of it.

You can just add simple span inside mj-text and use regular class with mj-style like that

<mj-style>
.foo { color: green; }
</mj-style>
<mj-text>
  <span class="foo">Hey !</span>
</mj-text>

All 6 comments

Hi @sinsunsan
I don't really understand the need of it.

You can just add simple span inside mj-text and use regular class with mj-style like that

<mj-style>
.foo { color: green; }
</mj-style>
<mj-text>
  <span class="foo">Hey !</span>
</mj-text>

ok, it is because I did not knew mj-style that is more that the css classes actually.

So mj-class add inline style on mj- elements
and mj-style add inline style on normal html elements ?

using the class system that is translated when compiling in html to inline style.
Is this correct ?

Adding a class on a mj-element won't work
adding a mj-class on a html eement won't work

mj-class allows you to add mj-attributes a MJML element like mj-text

mj-style no longer inline by default regular css on HTML element, everything define in mj-style can be use __only__ with HTML elements. If you want to inline it you can pass inline="inline" to mj-style.

To better undesrtand, mj-attributes is only for mj element and the only way to style them

<mj-text class="foo">

will not be evaluated ?

mj-text and other mjml elements
Could be styled only with attributes ?

What is inside the mj-text.... (span, ul li...) element are up to us and could be styled normally with css styles..
and managed with the mj-style element

For now, yes. There's a proposal to add css-class on any mj-element that should comes with 3.3.2

ok thanks :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zarikadzer picture zarikadzer  路  3Comments

valstu picture valstu  路  3Comments

hellfish2 picture hellfish2  路  4Comments

liminspace picture liminspace  路  3Comments

lucasnantonio picture lucasnantonio  路  4Comments