How to Display HTML Code in Blog Comments

  • Buffer
  • Pin It
  • Sharebar
  • Buffer
  • Pin It

You can easily display HTML code in a blog comment you leave on a blog. Unfortunately, it does require some minor changes to the HTML before you write it to the comment as regular HTML tags won’t usually be displayed properly, mainly due to security concerns.

When someone would like clarification about a particular piece of code, they attempt to paste it into the comments, but unfortunately, the code is removed and empty white-space is what appears. In this post I will describe how you can easily paste HTML code in your comment, not only on this blog, but probably any blog.

Showing HTML in a Web Page

When you would like to show actual HTML code in a Web page, you can’t simply type the HTML in a Web page and have it show up on the page. The browser would read that code and render it in the browser, instead of showing the actual code.

The trick to display actual code, like I have done with my Blogger template tutorials, is to replace a few characters with literal HTML character codes. You can also do this with blog comments.

Anyone who has coded in HTML knows that HTML is comprised of tags that are used to render information within the browser. The tags are surrounded by the less-than and greater-than brackets. If you want to display HTML code in a web page, or blog comments, you can replace the brackets surrounding the tags with literal HTML character codes.

This table shows the brackets and their corresponding HTML character code:

Character HTML Code
< &lt;
> &gt;

This means that to display this code in your blog comment, or web page:

<html>
  <head>
    <title>Title of the Web Page</title>
  </head>
  <body>
    <p>Some text.</p>
  </body>
</html>

You will need to enter the following:

&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Title of the Web Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;Some text.&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;

If you ever need to display HTML code in a blog comment or on a web page, you can use literal HTML character codes in your HTML to prevent the browser from interpreting and rendering your HTML.

 How to Display HTML Code in Blog Comments

About Paul Salmon

Paul Salmon is the founder of Technically Easy. He is a an experienced PC user, and enjoys solving computer-related problems that he encounters on a regular basis.

Facebook | Twitter | Google+

You may also like:

No thumbnail image

How to Display Web Code Examples in Your Web Site

Blogger Logo

Display a Blog List as a Static Page in Blogger

Blog Comments

10 Strategies for Getting More Blog Comments

Blogger Logo

How To Display Post Excerpts in Blogger

3 people had something to say about “How to Display HTML Code in Blog Comments”:

Comments


  1. <html>
    <head>
    <title>Title of the Web Page</title>
    </head>
    <body>
    <p>Some text.</p>
    </body>
    </html>


    • It seems to work.


  2. Well.. This is nice. But I’m wondering will there be any risk by putting this up?
    Andrew Walker recently posted…FitnessEquipmentExpress Coupon CodeMy Profile

Do you have something to say? Let everyone know!

Commenting policy: All comments are moderated for spam. You must use your real name and not your website name or keywords. If a comment is deemed to be spam, then it will be deleted or edited. Links to your website within the comment body is not permitted, but you are free to use CommentLuv to add a link to your latest post. If you wish to add a link to your website, you can always contact me about submitting a guest post.






CommentLuv badge
This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 5 approved comments. Use your real name and then @ your keywords (maximum of 3)

Previous Post:

Next Post: