Present Sample HTML in a Textarea Box
If you want to be standards compliant, then using an <xmp> tag won’t work to display your sample HTML. Instead, you could display the code inside of a <textarea> tag.
The <textarea> tag is typically used in forms. You know, the box you type a bunch of text into.
A lesser known function of the <textarea> is to display some HTML without rendering it. When you create a <textarea>, you can put some “default” text into it. If this default text contains HTML, the browser will simply ignore everything until it sees a </textarea> tag.
Here’s a quick example:
<textarea>
<p>Here’s some sample HTML.</p>
<p>This stuff will show up inside of the textarea
box and you will see <em>all</em> the tags.</p>
</textarea>
The output would be:
Here’s some sample HTML.
This stuff will show up inside of the textarea
box and you will see all the tags.
Simple. Effective. All you need to do is place your sample HTML between the <textarea> and the </textarea>.
There are a few problems with this, though.
Number one, you can’t display a <textarea> tag within your <textarea>. So that rules out creating examples of forms.
Number two, you can’t style the text at all. It’s bland. It’d be nice to make the text a bit larger and perhaps syntax highlight parts of it.
Using a <textarea> is a perfectly acceptable way to display sample HTML, and sometimes it may be the preferable way. However, there is another way.
You can escape the < and > characters, making the browser completely ignore all of the HTML.
Go back to the main guide: How to Display Sample HTML
Risa Castillion said this on March 31st, 2010 at 6:25 pm
I was thinking I would place a personal message in this article to demonstrate you the best way to produce money implementing dating affiliates together with absolutely free strategies. My partner and i were able to generate 5 thousand monthly using the methods inside the actual guide noted. Simply click here http://www.goarticles.com/cgi-bin/showa.cgi?C=2071953 to go through it.
Amie @ Patek Philippe Store said this on November 3rd, 2010 at 6:24 pm
Hi there, just stopped by doing some research for my Patek Philippe site. Can’t believe the amount of information out there. Wasn’t exactly what I was looking for, but great site. Have a great day.
Jonnie Kitagawa said this on November 12th, 2010 at 2:30 pm
Everyone loves your web blog!
Inflatable Hot Tub Covers said this on November 29th, 2010 at 5:05 pm
Your thoughts are spot on. Thanks for sharing this with us. – Chris
Eusebio Ducker said this on April 26th, 2011 at 8:46 pm
Thanks a lot for sharing this with all people you actually recognize what you’re speaking approximately! Bookmarked. Kindly additionally seek advice from my site =). We could have a hyperlink alternate contract between us!
farming simulator said this on April 30th, 2011 at 7:57 am
Thanks for a marvelous posting! I really enjoyed reading it, you could be a great author.I will be sure to bookmark your blog and will eventually come back later in life. I want to encourage you to definitely continue your great writing, have a nice afternoon!
los angeles plumbers said this on May 8th, 2011 at 12:46 am
The subsequent time I learn a blog, I hope that it doesnt disappoint me as much as this one. I mean, I do know it was my option to learn, however I truly thought youd have one thing fascinating to say. All I hear is a bunch of whining about one thing that you can fix if you werent too busy searching for attention. <a href=”http://www.ca-losangelesplumbing.com”>los angeles plumbers
rims camarillo said this on May 13th, 2011 at 4:14 pm
Howdy! http://www.breakersmobile.com I just would like to give an enormous thumbs up for the nice data you’ve gotten here on this post. I will probably be coming again to your blog for more soon.
African Mango Plus said this on May 17th, 2011 at 9:23 pm
Thanks so much for providing individuals with such a brilliant possiblity to read in detail from this blog. It is always so fantastic and also packed with a lot of fun for me and my office friends to search your website nearly three times in one week to see the new issues you have got. And of course, I’m just usually amazed with your cool knowledge served by you. Certain 3 areas in this article are rather the most effective I’ve ever had.
foot ball best players said this on May 22nd, 2011 at 10:29 pm
I can not tell if the post is much like by most people or is bashed by some, however all I can tell is that I will be liking this particular post more and more every time I review or reread it. And that i let you know I have again go through it once or twice by now.
cctv said this on May 24th, 2011 at 10:01 am
Just about all emotions as well as idealogy aside, I believe this has the potential to be your better works, may you keep producing this kind of quality in your long term writing. Thanks so much.
appliance repair San Fernando said this on May 26th, 2011 at 5:40 am
I’m impressed, I need to say. Really not often do I encounter a weblog that’s both educative and entertaining, and let me let you know, you will have hit the nail on the head. http://www.vipappliancerepair.com Your idea is excellent; the difficulty is one thing that not enough persons are speaking intelligently about. I am very comfortable that I stumbled across this in my search for something regarding this.
Los Angeles swimming pools said this on May 26th, 2011 at 12:34 pm
After research just a few of the weblog posts in your web site now, and I actually like your way of blogging. http://www.allstatepools.com I bookmarked it to my bookmark web site checklist and will likely be checking again soon. Pls take a look at my web site as properly and let me know what you think.
vegas betting said this on June 3rd, 2011 at 4:40 am
Like it. Thanks.
Talisha Corcino said this on June 15th, 2011 at 12:50 am
Go shopping for The air jordan 8-10 rich in excellent, numerous models as well as low cost charges. Mid-air Michael jordan Eight Popular, Water in your keep.
Eugenie said this on June 16th, 2011 at 9:57 pm
{You did|You probably did} {a great job|a fantastic job}….
Fantastic blog! I genuinely love how it’s easy on my small eyes as well as the facts are well written. I am wondering how I might be notified each time a new post has been made. I have enrolled in your rss feed which must do the trick! Have a nice day…
How To Get Pregnanteasily.net said this on July 13th, 2011 at 9:17 am
Hey there I am so grateful I found your weblog, I really found you by accident, while I was browsing on Google for something else, Anyways I am here now and would just like to say cheers for a tremendous post and a all round entertaining blog (I also love the theme/design), I don’t have time to browse it all at the moment but I have saved it and also added your RSS feeds, so when I have time I will be back to read more, Please do keep up the excellent work.
smart mobile phone said this on August 8th, 2011 at 4:08 am
Then a lot more friends can talk about this problem”
culinary schools in new york said this on August 15th, 2011 at 3:05 am
Spot on with this write-up, I truly suppose this web site needs much more consideration. I’ll in all probability be again to learn way more, thanks for that info.
My Online Income System said this on August 20th, 2011 at 9:33 pm
There is a lot of great information on this post. Thank You and keep it up.
Janitorial Services Illinois said this on August 22nd, 2011 at 9:16 pm
There are some interesting points in time on this article but I don’t know if I see all of them middle to heart. There’s some validity however I will take hold opinion until I look into it further. Good article , thanks and we want more! Added to FeedBurner as nicely
funny games wiki said this on August 28th, 2011 at 1:58 pm
I’m usually to blogging and i really respect your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for new information.
music downloads for free said this on September 1st, 2011 at 11:55 pm
Especially liked your piece, write some more.
On Demand Printing Services said this on September 8th, 2011 at 12:20 am
I found your blog web site on google and check a few of your early posts. Continue to maintain up the very good operate. I just extra up your RSS feed to my MSN News Reader. Seeking ahead to studying more from you in a while!…
Luxury Bali Villas said this on September 14th, 2011 at 3:40 pm
Amazing…
Thank you for provide good information about this, this content must be write by expert…
Wholesale Jerseys From China said this on January 4th, 2012 at 3:21 pm
Hello, I discovered your blog page in a new directory of blogs. I will not understand how your blog arrived up, must have been a typo, Your blog page looks very good. Have a good day