Monday, March 15, 2010

Displaying HTML Source Code in Blog Post

From the previous post I had a hard time displaying the HTML code that I was using.  Of course initially I thought I could easily just do a plug and code but I made two mistakes.

First mistake was that it would be easier if I plug the code into the WordPress text editor and it would convert the code for me and not interpret the code.  The other is that display was ugly.

To resolve this situation use the following HTML tags:
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both      spaces and
line breaks

This will not preserve spacing or formatting and display text as is.

W3School is great for all of this HTML code and CSS reference.

If you're not using WordPress and just want to display HTML code without it being interpreted you will need something to recode those special characters and symbols. I found this neat site that will convert it for you.

No comments:

Post a Comment