October 29, 2019
Advice I Wish I Could Take For Myself
How Do You Display HTML Tags?

To display HTML tags in a website, use their HTML encoding translation.

  • Replace the < character with &lt;
  • Replace the > character with &gt;
  • Replace the & character with &amp;

You don't actually have to encode the ">" character. That one will show as long as you encode the "<" character. So, you can write &lt;div> without encoding the > as &gt; and it will show like <div> when you write it. The & character you may have to escape in order to show the encoding of other characters. I did this in order to correctly display the information above.

I came across this issue when I was writing another post dealing with the list-style attribute and working with <ol>, <ul>, and <li>. I was like crap, how do I actually show this on the website itself. Damn, I have to encode it. So I looked up the html encoding translations and found this answer.

I'll be sure to add to this list should I come across different encodings that I need to use for this purpose.

 Profile Picture