How to add html code to a website but not have it actually turn to code?
I'm not sure how to describe this one. Basicly I want to show the coding of my website, in my website. So I'm not sure what tag to put. I've done some googling but i'm not even sure what I'm Googleing. I've found these tags, but none of them seemed to work. I found the script tag which I found out isn't what I needed and the code tag but that didn't do what I wante开发者_开发问答d. Anyone know what to do? Thanks in advance
write the <
as <
and the >
as >
(their character entity equivalents). This will prevent the browser from interpreting them as tags.
So instead of
<p>This is an <i>example</i> of html.<p>
You'd write
<p>This is an <i>example</i> of html.</p>
Tedious, but necessary. Technically speaking, a >
is only seen as a tag closer if it was preceded by a <
somewhere, so you MIGHT be able to get by with just doing <
-> <
, but it's safer to write out both characters in entity format.
Once that's done you may want to wrap it with the <pre>
tag (as in preformatted) which will cause the spacing and line breaks to be rendered just as they appear in your source code.
Utilize the HTML entity for each applicable symbol. Alternatively, you could use PHP and run the string through htmlentities.
I am not sure if you can do it with a simple tag, but I use this php library to convert my code to nice html code http://qbnz.com/highlighter/
take a look at this, i think it may be what you are looking for. http://code.google.com/p/google-code-prettify/
精彩评论