PDA

View Full Version : Here's a Question



Floppy
13 Dec 2007, 11:52 PM
I've seen this done before on other web pages, and I suppose I could find the answer by viewing the source code and sifting through a thousand lines of HTML, but I'd rather just ask someone!

How can I get HTML code to display as text on a Web page? For example, say I want to give a tutorial on basic HTML, and I want to show someone what a break tag or header tag looks like (so they can copy and paste it to their code), how can I do it without having it function as actual code within MY page? I'd rather not create "images of text" to use because these, for obvious reasons, cannot be ctrl+c'd and ctrl+p'd (plus they're a pain in the butt to work around.)

There's probably a simple answer, but this is one situation that HTML tutorials generally don't go into (and I've looked).

Thank you!

Love, Floppy

Wickham
14 Dec 2007, 01:28 AM
Characters like < act as code so the html code is operated by the browser and won't show as text in your page.

Substitute &lt; for < (and perhaps do the same for lots of other characters) and the html code will show as text. See
http://www.tedmontgomery.com/tutorial/HTMLchrc.html

So instead of <br> you type &lt;br> or &lt;br&gt; (I usually find that just changing the first character is enough as it disrupts the code as operated by the browser but you should really change them all).