The other day, I had to remove a bit of content in a WordPress post. It was related to an affiliate offer that had expired but I wanted to save the relevant text/code in case they brought the offer back. I thus decided to comment it out.
Sadly, it didn’t work right. This is what I tried to do:
<!-- RandomChunkOfTextIncludingHTML -->
The HTML comment tags (
-->) should have been enough to comment out the stuff in the middle, but that didn’t happen. Instead, it screwed up the layout of the rest of the page.
Why? Apparently because it couldn’t handle nested HTML tags. But I found a workaround. Instead of the above, I used:
<!-- RandomChunkOfTextIncludingHTML <!-- -->
In other words, I used an opening comment tag, and the comment with an opening and closing comment tag. Boom. Done. For the record, the same thing works on WordPress pages, too.