Back to Mjml

README

packages/mjml-section/README.md

5.1.05.7 KB
Original Source

mj-section

Sections are rows within your email. They will be used to structure the layout.

xml
<mjml>
  <mj-body>
    <mj-section full-width="full-width" background-color="red">
      <!-- Your columns go here -->
    </mj-section>
  </mj-body>
</mjml>

The full-width attribute will be used to manage the background width. Setting it will change the width of the section from the default 600px to 100%.

<div class="alert alert-note" role="alert"> <p>Note</p> <p>To invert the order in which columns display in the desktop view, first setup your columns in the order you want them to appear stacked in the mobile view and then add <code>direction="rtl"</code> to the <code>mj-section</code> tag.</p> </div> <div class="alert alert-caution" role="alert"> <p>Caution</p> <p><code>mj-section</code> tags cannot nest in other <code>mj-section</code> tags</p> </div> <div class="alert alert-important" role="alert"> <p>Important</p> <p>Limitations of <code>background-image</code> <code>background-size</code> and <code>background-position</code> in Outlook desktop :</p> <ul> <li>If <code>background-size</code> is not specified, <code>no-repeat</code> will be ignored in Outlook.</li> <li>If the specified <code>background-size</code> is a single attribute in percent, the height will be <code>auto</code> as in standard CSS. In Outlook, the image will never overflow the element, it will shrink instead of being cropped similar to other clients.</li> </ul> </div>

Attributes

attributeacceptsdescriptiondefault value
background-colorCSS color formatssection color
background-positionstringCSS values, i.e. left center right + top center bottom
(see outlook limitations below)top center
background-position-xstringCSS values, i.e. left center right
(see outlook limitations below)
background-position-ystringCSS values, i.e. top center bottom
(see outlook limitations below)
background-repeatrepeat no-repeatset the background image to repeat
background-sizestringCSS values e.g. auto cover contain px % sizeauto
background-urlstringbackground image, in URL format
borderstringCSS border format
border-bottomstringCSS border format
border-leftstringCSS border format
border-radiusstringborder radius
border-rightstringCSS border format
border-topstringCSS border format
css-classstringclass name, added to the root HTML element created
directionltr rtlset the display order of direct childrenltr
full-widthfull-width falsemake the section full-width
paddingpx %section padding, supports up to 4 parameters20px 0
padding-bottompx %section bottom padding
padding-leftpx %section left padding
padding-rightpx %section right padding
padding-toppx %section top padding
text-alignleft center rightCSS text-aligncenter
<p class="cta-container"><a class="cta" href="https://mjml.io/try-it-live/components/section">Try it live</a></p>