How can I show <&lt;> and <&gt;> in plain text in HTML?

Hi everyone.

I’m currently working on 'Build your own Cheatsheet" Project.
https://www.codecademy.com/paths/front-end-engineer-career-path/tracks/fecp-web-development-fundamentals/modules/fecp-challenge-project-build-your-own-cheat-sheet/projects/independent-project-html-documentation

It is written in the hint in step 2 that

Blockquote When displaying HTML tag names as text, you can’t just use the < or > characters, since your browser will think you are trying to create an actual HTML tag. In order to show HTML tags as text, use &lt; to represent < and $gt; to represent > .

I’d like to write this part in my HTML document but I am not able to write < and > in plain text. There are only < > symbols.

I have the same problem with the arrow symbol . I want to match the symbol to its hex code but the latter doesn’t appear.

Do you mean you want to be able to use &lt; and &gt; in your text-you want to say “To display < and > in HTML, use &lt; and &gt;.” If so, consider using the <code> tag. See this article for more information on it. As summary, the <code> tag is used to display text in a browser that might be interpreted as code-HTML or otherwise.

2 Likes

To add to what @codeneutrino said,

If you want to use the & sign, and have something follow it, without it being interpreted as another character you can use &amp;. This will display simply as &, then you can add anything else to it without it being displayed otherwise.

As for displaying the arrow, a number of codes for displaying symbols like such can be found here:

2 Likes

Yes, I want to write &lt; and &gt. I’m using the preformatted text function this time to write them! I hope it will work.

I tried the code tag but it doesn’t work.

I believe you will have to use the &amp; for this.
For example, to get &lt; to be displayed you need to write, &amp;lt

1 Like

You’re right @8-bit-gaming ! &amp;lt is working! :smiley:

I already found the hex code for the arrow &#x2794 but it didn’t appear. However since it is the same symbol & at the beginning, your solution perfectly works! :clap:

Thanks a lot!

1 Like