<br> needs extra empty line

AI-generated summary

Users are discussing an issue where <br> tags fail to render properly in Discourse posts unless followed by an empty line, which affects spacing and layout—particularly in examples involving HTML elements like <kbd>. Jagster first reports the bug, noting that adding a blank line after <br> fixes it, and that this breaks existing content using <br> for spacing. Moin confirms encountering the same issue in a different context and resolves it by removing <br> until learning the empty-line workaround. Sam clarifies this isn’t a bug but a result of CommonMark’s parsing rules, which treat <br> as a multi-line HTML element, altering how surrounding Markdown is processed. Lilly offers a workaround using a backslash (\) to force line breaks. Jagster counters that this behavior is new and disruptive, and Jagster further demonstrates that even self-closing <br /> fails unless preceded by an empty line, suggesting the issue is more systemic than just CommonMark quirks. The thread highlights a UX impact on forums relying on HTML for formatting, especially where spacing is critical, and implies that recent changes to Markdown parsing may have introduced this regression.

This doesn’t work

<br>
<kbd>[wrap=icon id=fa-share][/wrap]&nbsp;Reply</kbd>

[wrap=icon id=fa-share][/wrap] Reply

But this works:

<br>

<kbd>[wrap=icon id=fa-share][/wrap]&nbsp;Reply</kbd>

 Reply

This can be a UX/UI-question too, but because it worked earlier, I count it as a bug.

Not a biggie, though. But it can affect every situation when a HTML-tag is used. In my forum it broke almost every helps where an example-button is used or I’ve needed extra space after an image.

2 Likes

I also had that problem yesterday at User Card Directory: message button should not show on mobile - #5 by Moin. I wasn’t able to figure out why the link did not work:

So, in the end, I removed the <br>. And now I was able to add it again because you told me that all I needed to fix it was an empty line. Thanks.

1 Like

This is not really a bug, it is just commonmark spec which makes mixing html and markdown somewhat quirky.

When you do <br> it thinks it is a multi line html element, so certain rules do not kick in.

1 Like

this works:

\
<kbd>[wrap=icon id=fa-share][/wrap]&nbsp;Reply</kbd>


 Reply

1 Like

Before kicked in, so those certain rules are only few days old :man_shrugging:

No can do then and I have to start fix posts manually.

I still claim there is something more, because that quirky thing stops totally <br>.

<br>
<kbd>[wrap=icon id=fa-share][/wrap]&nbsp;Vastaa</kbd>

<br />
<kbd>[wrap=icon id=fa-share][/wrap]&nbsp;Vastaa</kbd>

<kbd>[wrap=icon id=fa-share][/wrap]&nbsp;Vastaa</kbd>

[wrap=icon id=fa-share][/wrap] Vastaa
[wrap=icon id=fa-share][/wrap] Vastaa

 Vastaa