Post HTML code to blog using HTML Entity Code

You may have noticed in viewing tutorials on the web, xhtml code can be displayed directly on a web page; the browser does not render it as code, but allows it to remain as visible text.

So, how can this be accomplished?

  • The < left bracket can be visually displayed on your web page by using the special character of &lt; which is the “less than” character.
  • Same with the > right bracket. The special character to use is &gt; which is the “greater than” character.
  • The [ should be replaced by
  • And the ] by ]

For example, to visually display the following code on a web page:

<p>paragraph text here.</p>

The actual (x)html code would look like this:

&lt;p&gt;paragraph text here.&lt;/p&gt;

 

1. You can do the conversion (ASCII characters to HTML entity code) manually by using the HTML ASCII Reference

2. Or you can use an assistance program like SimpleCode which will help you do the same thing, but faster than you do it manually. 

Note: SimpleCode also will automatically add the <code></code> tag to your code.  This tag informs the browser that the contained text should not be rendered as real code, but should be visually displayed on the web page as example code. Most browsers, by default, will format the text in a monospace font – just like in Notepad.

 

To learn more about <code> tag, and <pre> tag see this post.

Also WordPress.com has a specific tag for you to post code: the tag. To learn more how to use this tag, see this post.

Advertisements
%d bloggers like this: