Displaying < on the page

Currently working on a technical documentation page about HTML using the MDN page as reference and there’s a bit where I need to display various XML codes like < and " ON the page. Only problem is I can’t find a way to write that in the code and have it actually be displayed on the page without it rendering a less-than or quote symbol.

Heres the HTML and CSS code I’m using on my page:

HTML

<div class="code-container">
      <pre>
        <code>
          &lt;
        </code>
      </pre>
    </div>

CSS

.code-container{
  max-width: 80%;
  background-color: #434546;
  margin: 25px 0 0 40px;
  min-height: 50px;
  border-radius: 5px;
  text-align: left;
  height: auto;
  vertical-align: middle;
}

pre code{
  font-family: monospace;
  font-size: 1.09rem;
}

Any help with this would be awesome.

Actually, your code is working. Try to move the ‘background-color’ property from the .code-container selector and you will see the < .
For more information on this topic read:

(post deleted by author)

My problem is that it is displaying < when I want it to display & l t; like on this page at MDN. I just realized that when I wrote & l t and &q o u t in the post above the browser rendered them as the symbols instead of text. Should’ve thought about that, sorry.

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