Back to Mjml

README

packages/mjml-image/README.md

5.1.05.5 KB
Original Source

mj-image

Displays a responsive image in your email. It is similar to the HTML `` tag.

Note that if no width is provided, the image will use the parent column width.

xml
<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-image width="300px" src="https://static.mailjet.com/mjml-website/documentation/image.png" />
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

Attributes

attributeacceptsdescriptiondefault value
alignleft center rightimage alignmentcenter
altstringimage description''
borderstringCSS border format0
border-bottomstringCSS border format
border-leftstringCSS border format
border-radiusstringborder radius
border-rightstringCSS border format
border-topstringCSS border format
container-background-colorCSS color formatsinner element background color
css-classstringclass name, added to the root HTML element created
fluid-on-mobilebooleanif true, will be full width on mobile even if width is set
font-sizepxsize of the alt text when image is not rendered13px
heightpximage heightauto
hrefstringlink to redirect to on click, in URL format
max-heightpx %specify the maximum height of an image
namestringspecify the link name attribute
paddingpx %hero padding, supports up to 4 parameters10px 25px
padding-bottompx %hero bottom padding
padding-leftpx %hero left padding
padding-rightpx %hero right padding
padding-toppx %hero top padding
relstringspecify the rel attribute
sizesstringset width based on query
srcstringimage source in URL format
srcsetstringenables to set a different image source based on the viewport, using CSS syntax
targetstringlink target on click_blank
titlestringtooltip & accessibility
usemapstringreference to image map, be careful, it isn't supported everywhere
widthpximage widthinherits parent width
<p class="cta-container"><a class="cta" href="https://mjml.io/try-it-live/components/image">Try it live</a></p>