I want the output in my window to show the actual "<!-- -->"
. How do I quote that so it prints out?
Same for printing out <h2>Text Here</h2>
- I want it to actually print that out, and not do the <h2>
style.
Asked
Active
Viewed 26 times
1 Answers
1
Method 1: Escape characters (recommended option)
<
is <
>
is >
Have a look at this code snippet:
This will appear as a comment:
<br><!-- Test -->
<br>
<br>This will actually appear:
<br><!-- Test -->
You can find out how to escape characters here: https://ascii.cl/htmlcodes.htm
Method 2: Use the xmp
tag
Warning: this feature is discouraged by MDN webdocs:
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/xmp
This will appear as a comment:
<br><!-- Test -->
<br>
<br>This will actually appear:
<br><xmp><!-- Test --></xmp>

Community
- 1
- 1

Run_Script
- 2,487
- 2
- 15
- 30
-
the < and > worked perfectly! thanks – DeAnna Apr 14 '20 at 15:48
-
No problem, I'm glad it worked! – Run_Script Apr 14 '20 at 15:58
-
@mplungjan When I began writing my question, there were no answers here, so I didn't copy you! It can happen that several people give the same answer – there are only so many solutions out there, and these are the only two that I can think of. – Run_Script Apr 14 '20 at 16:21