How can I display HTML tags on a page?

I want to have the browser treat a section of the file as text rather than html code. Is there a way to have a browser treat a section as text and display it as is instead of thinking it is html tags and potentially messing up the page?

I am mostly interested in this as it would be useful when displaying sample HTML on a post.

Thank you.

After doing some research, I found two ways to display html tags on a page. One involved replacing the characters ‘<‘ and ‘>’ with &lt; &gt; and ” to &quot. The other alternative I found which I prefer is using the “Code” tag. However, I was not able to use the <code> tag as shown below:

<code>

<a href="http://JCBauza.com">My site</a>

</code>

but rather I had to do a combination of both. From the looks of it the <code> tag only allows for special formatting by the browser:

<code>

<p>

&lt;code&gt;

</p>

<p>

&lt;a href="http://JCBauza.com"&gt;My site&lt;/a&gt;</p>

<p>

&lt;/code&gt;</p>

<p>

&nbsp;</p>

</code>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: