Back to Mjml

README

packages/mjml-table/README.md

5.1.04.5 KB
Original Source

mj-table

Display a data table. It only accepts plain HTML.

xml
<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-table>
          <tr style="border-bottom:1px solid #ecedee;text-align:left;padding:15px 0;">
            <th style="padding: 0 15px 0 0;">Year</th>
            <th style="padding: 0 15px;">Language</th>
            <th style="padding: 0 0 0 15px;">Inspired from</th>
          </tr>
          <tr>
            <td style="padding: 0 15px 0 0;">1995</td>
            <td style="padding: 0 15px;">PHP</td>
            <td style="padding: 0 0 0 15px;">C, Shell Unix</td>
          </tr>
          <tr>
            <td style="padding: 0 15px 0 0;">1995</td>
            <td style="padding: 0 15px;">JavaScript</td>
            <td style="padding: 0 0 0 15px;">Scheme, Self</td>
          </tr>
        </mj-table>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>
<div class="alert alert-note" role="alert"> <p>Note</p> <p><code>mj-table</code> is an "ending tag", which means that it can contain HTML code but it cannot contain other MJML components. Therefore, it will accept any tag you would add inside an HTML table tag.</p> <p>More information about ending tags <a href="#ending-tags">in this section</a>.</p> </div>

Attributes

attributeacceptsdescriptiondefault value
alignleft right centertable horizontal alignmentleft
borderstringCSS border formatnone
cellpaddingintegerspace between cells0
cellspacingintegerspace between cell and border0
colorCSS color formatstext header & footer color#000000
container-background-colorCSS color formatsinner element background color
css-classstringclass name, added to the root HTML element created
font-familystringfont nameUbuntu, Helvetica, Arial, sans-serif
font-sizepxfont size13px
line-heightpx %space between lines22px
paddingpx %outer table padding, supports up to 4 parameters10px 25px
padding-bottompx %bottom padding
padding-leftpx %left padding
padding-rightpx %right padding
padding-toppx %top padding
rolenone presentationspecify the role attribute
table-layoutauto fixed initial inheritsets the table layoutauto
widthpx % autotable width100%
<p class="cta-container"><a class="cta" href="https://mjml.io/try-it-live/components/table">Try it live</a></p>