I want to display code characters on an html page. But no matter what i try it always renders html characters. Pre or code doesnt work. How can I do this?
+2
A:
You need to use character references instead of the plain characters themselves:
<code><HTML></code>
The elements code
and pre
are just to mark the content as code or preformated.
Gumbo
2009-11-18 13:58:14
+2
A:
By escaping them.
&
will print &
<
will print >
You didn't mention what you're using to generate the html, if you're manually editing, some editors have options to escape a selection. If you're using a language, look for some function that escapes html special characters. (google for how to escape html in language-name-here
)
Prody
2009-11-18 13:58:32
A:
The <xmp>
tag doesn't require the contents to be escaped.
eg:
<xmp>
<p>Blah </p>
</xmp>
...will look like this on your screen:
<p>Blah </p>
nickf
2009-11-18 14:02:31
A:
Look for an HtmlEncode function in your language.
string s = HtmlEncode(myInput); response.write(s)
or similar
No Refunds No Returns
2009-11-18 14:03:14