# Problem with \<code\> tag

**URL:** <https://forum.freecodecamp.org/t/problem-with-code-tag/445561>\
**Category:** Curriculum Help\
**Tags:** css, html\
**Created:** [February 10, 2021, 5:13pm UTC](https://forum.freecodecamp.org/t/problem-with-code-tag/445561 "2021-02-10T17:13:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kerry.wick](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kerry.wick/32/134071_2.png) [@kerry.wick](https://forum.freecodecamp.org/u/kerry.wick)\
**Post date:** [February 10, 2021, 5:13pm UTC](https://forum.freecodecamp.org/t/problem-with-code-tag/445561/1 "2021-02-10T17:13:42Z")

</div>

Hi! I am working on the Technical Documentation project. My documentation is about  
DITA XML/ Markdown syntax. I tried putting some DITA snippets inside the html  
`<code>` tag and VS code parses it as regular code. So I tried putting a `<pre>` tag around the DITA and that did not solve the problem. Here are the snippets.

```auto
  <code>
                <!--start code 
                    <topic id="topic_title">
                    <title>Topic title</title>
                    <topic id="nested_topic_title">
                      <title>Nested topic title</title>
                    </topic>
                  </topic> -->
            </code>

```

---

<div class="post-metadata">

**Author:** ![kerry.wick](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kerry.wick/32/134071_2.png) [@kerry.wick](https://forum.freecodecamp.org/u/kerry.wick)\
**Post date:** [February 10, 2021, 5:15pm UTC](https://forum.freecodecamp.org/t/problem-with-code-tag/445561/2 "2021-02-10T17:15:35Z")

</div>

I have figured out with using special characters how to get the code snippets to display, however I am not getting the whitespace I need to indent some of the code snippet lines where they are nested. to render in the output.

```auto
<pre><code>&lt;topic id="topic_title"&gt;
                <!-- needs 1 tab whitespace -->&lt;title&gt;Topic title&lt;/title&gt;
               <!-- needs 1 tab whitespace --> &lt;topic id="nested_topic_title"&gt;
                  <!-- needs 2 tabs whitespace -->&lt;title&gt;Nested topic title&lt;/title&gt;
                &lt;/topic&gt;
              &lt;/topic&gt;</code>
            </pre>

```

---

<div class="post-metadata">

**Author:** ![bbsmooth](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bbsmooth/32/203556_2.png) [@bbsmooth](https://forum.freecodecamp.org/u/bbsmooth)\
**Post date:** [February 10, 2021, 5:18pm UTC](https://forum.freecodecamp.org/t/problem-with-code-tag/445561/3 "2021-02-10T17:18:57Z")

</div>

If you want to show us your code here then you need to wrap it with three backticks (three backticks on a line by itself, then your code below, then three more backticks after your code on a line by itself).

---

<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:** [February 10, 2021, 5:21pm UTC](https://forum.freecodecamp.org/t/problem-with-code-tag/445561/4 "2021-02-10T17:21:21Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](http://www.freecodecamp.com/forum/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![Roma](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/roma/32/112899_2.png) [@Roma](https://forum.freecodecamp.org/u/Roma)\
**Post date:** [February 10, 2021, 5:27pm UTC](https://forum.freecodecamp.org/t/problem-with-code-tag/445561/5 "2021-02-10T17:27:53Z")

</div>

To display and not get the code snippet interpreted you’ll need to change the angle brackets into their respective HTML entities.

And on a side note, you don’t nest `pre` within `code`, it’s the other way around.

---

<div class="post-metadata">

**Author:** ![kerry.wick](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kerry.wick/32/134071_2.png) [@kerry.wick](https://forum.freecodecamp.org/u/kerry.wick)\
**Post date:** [February 10, 2021, 5:30pm UTC](https://forum.freecodecamp.org/t/problem-with-code-tag/445561/6 "2021-02-10T17:30:42Z")

</div>

Ok thanks! Sorry about the confusion with formatting of my code snippet folks.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [August 12, 2021, 5:31am UTC](https://forum.freecodecamp.org/t/problem-with-code-tag/445561/7 "2021-08-12T05:31:25Z")

</div>

Closed on August 12, 2021, 5:31am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
