Current location: Hot Scripts Forums » General Web Coding » HTML/XHTML/XML » Displaying html code


Displaying html code

Reply
  #1 (permalink)  
Old 01-31-07, 09:37 AM
jbsniff jbsniff is offline
Newbie Coder
 
Join Date: Oct 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Displaying html code

Let's say I was writing an html tutorial and I wanted people to be able to see my html code. Now if I just wrote it the browser would parse it as html and I would see a text box (for example). I want people to see the code. (<input type = "text" />)

Do any of you know how to tell the browser that the html is not markup but text?
Reply With Quote
  #2 (permalink)  
Old 01-31-07, 10:02 AM
coolmark18's Avatar
coolmark18 coolmark18 is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
use the xmp tags.

So
Code:
<xmp> <a href="mysite.com">Hello<a/> </xmp>
would display

Quote:
<a href="mysite.com">Hello<a/>
Reply With Quote
  #3 (permalink)  
Old 01-31-07, 11:17 AM
jbsniff jbsniff is offline
Newbie Coder
 
Join Date: Oct 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
I figured it out, thanks.

for those interested I was actually embedding html inside a <textarea></textarea>. The problem was when I put a textarea inside those two tags the ending textarea </textarea> would end the first one.
observe:
<textarea>
<textarea>

</textarea> <- This text area tag stopped the first one, not the second.
</textarea>

All I had to do was use the php function htmlentities(). For more information check here .
__________________
my portfolio: http://www.PartDigital.com

Last edited by jbsniff; 01-31-07 at 11:25 AM.
Reply With Quote
  #4 (permalink)  
Old 01-31-07, 12:12 PM
jfulton's Avatar
jfulton jfulton is offline
Community VIP
 
Join Date: Apr 2006
Location: Los Angeles, CA
Posts: 660
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, anytime you are using "html" characters (<, >, &, ") you should escape them. If you don't have php, you can just type them in manually (&lt;, &gt;, &amp;, &quot;)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
html tutoral thefrtman HTML/XHTML/XML 5 04-27-09 10:25 AM
Can I insert PHP code into HTML ?? cc79 HTML/XHTML/XML 5 04-12-08 11:00 AM
How do i make a CODE box in HTML? konabiker47 HTML/XHTML/XML 4 11-13-05 07:00 PM
Referencing HTML code from a second file msoucy HTML/XHTML/XML 2 07-18-05 12:25 AM
Can anyone help me ? (problem using php variables in html db insert code) chronic_ PHP 2 06-13-04 11:19 AM


All times are GMT -5. The time now is 08:56 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.