I have a page that has three tables on it. When the viewport is under a certain size, I display an alternate layout that's more mobile-friendly. This works great for the first section. However, when I include the mobile-friendly markup in the second section of the same page, the outputted HTML is severely mangled.
The snippet below is the code in question. It is copy-pasted from the previous section. When this code is present in the 2nd section, everything after this is totally mangled (emitted incorrectly and outside of the containing tag):