To format the output, you can use the pre element.
However, you still have to turn the special < > ' " & characters into your HTML objects < > etc., so that the HTML tags are displayed in clear text and not displayed by the browser.
If you can use PHP , there are htmlspecialchars () for this. Each server-side scripting language has an equivalent.
In JavaScript, setting the innerText property in the pre container causes characters to appear literally, rather than as interpreted HTML.
If you want to do this manually, this is what you need to convert:
& to & > to > < to < " to " ' to '
a source
source share