XHTML- Showing Code

Posted by Katie on July 24, 2009

It's very easy to show html or xhtml (or any code) on your website. All you do is replace the triangle brackets with asci code.

  • < turns to &lt;
  • > turns to &gt;

Then you type your code normally and use <br /> to make spaces between the lines.

Here is a short example:
&lt;img src="blah.gif" /&gt;

If you want to make your code look different than the normal text on your page, here's a little taste of css. Add

<div class="code"> blah </div>

around the code you want to display, and then add (and feel free to edit) this code to your css:

div.code {
font: 12px courier new;
border: 1px solid #d1d3d4;
background: #f1f1f1;
width: 50%;
padding: 3px;
}

That's all there is to it!



Write a comment