Google Prettify wasn't displaying HTML properly for me until I found on stackoverflow that I should replace all the <
with <
and all the >
with >
.
Is this really necessary? Is there an easier way to accomplish this?
I want to display simple code like the following:
<h1>Header</h1>
<p>This is a paragraph tag. Here is a <a href="#">LINK</a></p>
Is there something I can use that will detect everything as code between the <pre>
tags? For example, as I type code in at stackoverflow, I'm not required to replace the <
and >
.
You could create a form with PHP to take the inputted HTML and replace the HTML tags using the PHP function htmlentities() OR you could use this URL I stumbled upon looking for a solution for you. http://www.boallen.com/htmlentities.html You input your code and it will output your code with htmlentities applied.
Not sure what your knowledge of PHP is but you can read how the function works here: https://www.php.net/manual/en/function.htmlentities.php