The closing <div>s inside HTML comment blocks appear outside the comment which makes the exported HTML invalid. For example: #+title: Stray div demo Hello. #+html: <!-- * Heading ** Subheading #+html: --> Goodbye. Produces this HTML (cleaned up to make it easier to read, see attached for original files): <p>Hello.</p> <!-- <div> <h2>Heading</h2> <div> </div> <div> <h3>Subheading</h3> <div> --> <p>Goodbye.</p> </div> </div> </div> Emacs : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2024-03-08 Package: Org mode version 9.6.15 (release_9.6.15 @ /home/jm/.local/share/emacs/30.0.50/lisp/org/)