How can i get a scroll box that displays HTML code inside?

I would like to create a really small scroll box ( 93 x 35 px) but i would like to display html code in it so others can copy the code from inside. Ive tried googleing it but its all very complicted with the whole replacing < with < and > with > . i would just like someone to post the whole code with a section saying TEXT HERE for me to insert my html code please (haha). and i know this quesiton has probably been asked a million times so sorry, but none of the answers i found were very clear :S well thankyou i hope i get replies.
 
Ideally, you should never expose code to the end user, but I can understand that there's a situation where you might need to.

You don't have to replace >'s just <'s because they START tags, you just need to replace it with: <

Don't use a text box for that though*, just use a pre-formatted block (<pre />), and put the text inside, if you want the scroll bars, add a class (like <pre class="code" />) and add something to your stylesheet, like:

.code {
overflow: scroll;
}

* The reason not to use a text box is because Text boxes NEED to be in forms, unless they're the ROOT element in the document. There's no guarantee that your document will display right if it breaks an HTML rule like that. Text boxes are for users to type text into, not the programmer.

Hope this helps, email me if you need anything =)
 
Back
Top