# \<Code\> element to add HTML code

**URL:** <https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056>\
**Category:** General\
**Created:** [March 15, 2019, 12:14am UTC](https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056 "2019-03-15T00:14:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![NewIncome](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/newincome/32/110923_2.png) [@NewIncome](https://forum.freecodecamp.org/u/NewIncome)\
**Post date:** [March 15, 2019, 12:14am UTC](https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056/1 "2019-03-15T00:14:03Z")

</div>

Hi,  
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!!

---

<div class="post-metadata">

**Author:** ![shimphillip](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shimphillip/32/158663_2.png) [@shimphillip](https://forum.freecodecamp.org/u/shimphillip)\
**Post date:** [March 15, 2019, 12:20am UTC](https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056/2 "2019-03-15T00:20:23Z")

</div>

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

You can use a tool like this.

[https://www.freeformatter.com/html-escape.html#ad-output](https://www.freeformatter.com/html-escape.html#ad-output)

---

<div class="post-metadata">

**Author:** ![NewIncome](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/newincome/32/110923_2.png) [@NewIncome](https://forum.freecodecamp.org/u/NewIncome)\
**Post date:** [March 15, 2019, 1:34am UTC](https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056/3 "2019-03-15T01:34:00Z")

</div>

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

Thank you very very much!!!

---

<div class="post-metadata">

**Author:** ![NewIncome](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/newincome/32/110923_2.png) [@NewIncome](https://forum.freecodecamp.org/u/NewIncome)\
**Post date:** [March 15, 2019, 1:39am UTC](https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056/4 "2019-03-15T01:39:39Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![shimphillip](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shimphillip/32/158663_2.png) [@shimphillip](https://forum.freecodecamp.org/u/shimphillip)\
**Post date:** [March 15, 2019, 1:48am UTC](https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056/5 "2019-03-15T01:48:33Z")

</div>

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.

[https://www.w3schools.com/tags/tag\_pre.asp](https://www.w3schools.com/tags/tag_pre.asp)

---

<div class="post-metadata">

**Author:** ![NewIncome](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/newincome/32/110923_2.png) [@NewIncome](https://forum.freecodecamp.org/u/NewIncome)\
**Post date:** [March 15, 2019, 2:01am UTC](https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056/6 "2019-03-15T02:01:12Z")

</div>

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.)

 ![Code%20Element%20example-01](https://global.discourse-cdn.com/freecodecamp/original/3X/5/1/515046af8b07988b3847ecfc542208d02a65d547.png)

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

 ![Code%20Element%20example-02](https://global.discourse-cdn.com/freecodecamp/original/3X/b/d/bdedfe7d2c4d7a24035f86dcb55efa2ef1ef51c9.png)

Let me know what you think.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:04pm UTC](https://forum.freecodecamp.org/t/code-element-to-add-html-code/265056/7 "2021-01-17T20:04:10Z")

</div>

Closed on January 17, 2021, 8:04pm UTC


