<Code> element to add HTML code

I’ve been having a lot of problems trying to add html code as text in my page. Do you know of the correct way of doing this?? Apparently for any other language there is no problem but if you try to add html as the text it doesn’t see it a just text.
Please help!!

You need to escape html tags inside <code> block, otherwise it will output as it is.

You can use a tool like this.


With HTML Entity AWESOME!!! I had already tried with ascii and unicode and didn’t work.

Thank you very very much!!!

1 Like

One last question @shimphillip, would you happen to know why I searched some pages and “Inspected” their code while doing what I am trying to do and they do not use this method. They directly had the code inside <pre> tags.

jejeje Awesome btw, thanks again!

hmm, not sure why some codes would work without html entities. Do you have an example link?

<pre> tag just helps you with formatting. It will preserve the format in which you type in.

Here is an example.


Right. I do use a lot w3schools a lot for my actual learning and practice.
Well check this out. I’m sure there something I don’t know here (a lot actually):
(On this first image I think they didn’t do anything special, but maybe something it the attributes.)

Woooow, check this second image out!! On this page they get, I would say way to complex for just the tags:

Let me know what you think.