Monday, April 25, 2011

Displaying Code in HTML

Found this out today - If you're going to include code in your blog post/web page, there's a few ways to do it.

1.  Add a html object that creates a code-quoting area that isn't parsed by html
2.  Use <pre><code>code here</code></pre>.  I had mixed results.
3.  Just be aware of HTML's special character codes.  In my case, I'm not a super HTML wizard, I don't have a slick HTML customization GUI (google's blogspot isn't feature-rich), and I needed to color and customize the text so I couldn't just copy paste into the HTML code section.

Some Tips on option #3:
< >  Use
& l t ; (no spaces) for <
and
& g t ; (no spaces) for >

to avoid this hassle when you're composing your blog.
Watch out for words like Object: formatted  in the correct way, this can cause headaches
(<object> added a video in place of my text).

 List of special characters:
http://htmlhelp.com/reference/html40/entities/special.html

Nifty link to add <> symbols to your words:
http://accessify.com/tools-and-wizards/developer-tools/quick-escape/default.php

No comments:

Post a Comment