I'm looking for the best way to show html-tags as text in a HTML document. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

I'm looking for the best way to show html-tags as text in a HTML document.

Hi, everone, I'm looking for the best way to show html-tags as text in a HTML document. Like how to show ' <p> I'm a paragraph</p>' as text, without the html tags disappear, in a html document. Thanks to taking the time to helping me. wanna.be/webdesigner :-) ! Keep coding!

16th Apr 2019, 7:42 PM
wannabe.be/webdesigner
3 Answers
+ 6
In order to use such characters, you need to use escape characters. <p></p> would be written as: & lt;p& gt; &lt;/p& gt; I had to add a space between the & symbol and the two letters as it just reverts to normal angled brackets so remember to remove the spaces when testing.
16th Apr 2019, 8:02 PM
Logomonic Learning
Logomonic Learning - avatar
+ 6
You can do that with javascript. For example, if you wan to write "<test>Hello</test>" in the element with id "me", use: document.querySelector("#me").innerText += "<test>Hello</test>";
16th Apr 2019, 10:15 PM
InvBoy [ :: FEDE :: ]
InvBoy [ :: FEDE :: ] - avatar
+ 1
You can use <code></code> attribute
23rd Apr 2019, 1:43 PM
Omar Ezz Eldin
Omar Ezz Eldin - avatar