Show Code Snippets In Your Blog Post Or Webpage
- Insert plain text into a webpage
- Creates scrollable pane for viewing contents
- Text or code can be easily copied
- Works in Blogger or other webpages
- No javascipt or fancy server-side stuff
This tip is great if you want to insert some example CSS or HTML code into a post on your blog. I use this method for this article.
Copy your code and paste it in the top panel at SimpleCode.
Hit 'Process'. Copy the result, but not the Code tags at top and bottom.
Paste into your blog post or webpage, wrapped by the following TEXTAREA tags.
How It Works
Your browser wants to process HTML code it sees, so you need to use 'escape' codes in place of angled brackets. Putting the code into a TEXTAREA allows it to be selected and copied from a scrollable window. Adjust 'cols' and 'rows' as required.
Make sure to strip out unnecessary line breaks and white spaces.
If your code snippet is short and you don't need a scrollable pane you can paste straight into BLOCKQUOTE tags, keeping the CODE tags around the SimpleCode output.