#3112·mjml

When any `mj-selector` element is present, `<br>` elements are sometimes compiled to `<br></br>`

Author: emma-k-alexandraCreated Jun 25, 2026Updated Aug 6, 2026

Describe the bug <br> is getting compiled to different things based on if an mj-selector element is present in the MJML. It does not seem to matter if the mj-selector actually selects the block the <br> is in.

To Reproduce Case 1: Example without mj-selector: https://mjml.io/try-it-live/To2DOPgd8

In this example,

xml
...
<mj-text css-class="custom">
  <p>
    Hello World!<br>
  </p>
</mj-text>
...

is compiled to

xml
...
<p> Hello World!<br>
</p>
...

Case 2: Example with mj-selector, <br> is compiled to <br></br>: https://mjml.io/try-it-live/vjWLQhb0L

In this example,

xml
...
<mj-text css-class="custom">
  <p>
    Hello World!<br>
  </p>
</mj-text>
...

is compiled to

xml
...
<p> Hello World!<br>
  </br></p>
...

Note that the path of the mj-selector does not actually select the mj-text the <br> is in.

Case 3: Example with mj-selector but <br> is compiled to <br />: https://mjml.io/try-it-live/mjLo-DtRrc

In this example, the <br> is not placed in a <p>.

xml
...
<mj-text css-class="custom">
  Hello World!<br>
</mj-text>
...

is compiled to

xml
...
Hello World!<br />
...

Again, the path of the mj-selector does not actually select the mj-text the <br> is in.

Expected behavior Adding an mj-selector should not change what <br> is compiled to.

MJML environment (please complete the following information):

  • MJML Version 5.3.0
  • MJML tool used Try it Live