Wednesday, September 17, 2008

How do you show "<" and ">" on your blog page?

Dot .Net Dilemmas
In yesterday's blog I was trying to show an entry in a web.config file and I couldn't get the "<" to be displayed correctly so, my output was displayed as:
compilation defaultlanguage="c#" debug="false"

when of course I wanted to display it as:
<compilation defaultlanguage="c#" debug="false">

Turns out to be very simple (once you know how)
&lt; = <
&gt; = >

So
&lt;compilation defaultlanguage="c#" debug="false"&gt;
Would display as
<compilation defaultlanguage="c#" debug="false">
That's it.

Another you might need to use is:
&quot; = "

And while I'm at it, if you want to actually display &lt; and not < etc. on your blog:
Use &amp; before the &lt;

No comments: