Displaying Sample Code in a Web Browser.
August 17, 2007
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 “<” and the closing “>” with “>”. So, in the code view of whatever editor you prefer to use, it would look like this.
< h1>This is a Heading< /h1 >
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.
October 6, 2007 at 12:27 pm
would the browser still read it correctly?