One of the hardest things for beginner or casual web developers is figuring out how to tell a browser not to translate code and to display the code “as is” in the browser window. A quick work around for this is to encode the < and > symbols at the beginning and end of the block of code you want to display.

So if I want to display the code for this:

This is a Heading

I would need to replace all “<” tag with “&lt;” and the closing “>” with “&gt;”. So, in the code view of whatever editor you prefer to use, it would look like this.

&lt; h1&gt;This is a Heading&lt; /h1 &gt;
And the web browser will display it as this:

< h1>This is a Heading< /h1 >

I hope this first post has been helpful. For any questions, please feel free to contact me.

One Response to “Displaying Sample Code in a Web Browser.”

  1. trentz Says:

    would the browser still read it correctly?


Leave a Reply