1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Showing HTML to the end user.

Discussion in 'HTML & Website Design' started by avkinfo, Dec 5, 2006.

  1. #1
    I am trying to create a webpage that will show the end user a HTML script, however, when I show it on the page, it simply gets parsed by the browser. What I want, is to show the raw HTML code to the user, not the output.
     
    avkinfo, Dec 5, 2006 IP
  2. dilute

    dilute Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use <pre> <textarea> or replace all the < with & codes i.e. &lt; and &gt; then rep me
     
    dilute, Dec 5, 2006 IP
    avkinfo likes this.
  3. Monty

    Monty Peon

    Messages:
    1,363
    Likes Received:
    132
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can use the tag <pre></pre> & <code></code> :

    <pre>
    <code>&lt;html&gt;</code>
    	<code>&lt;head&gt;</code>
    	<code>&lt;/head&gt;</code>
    	<code>&lt;body&gt;</code>
    		<code>Some text here</code>
    	<code>&lt;/body&gt;</code>
    <code>&lt;/html&gt; </code>
    </pre>
    Code (markup):
     
    Monty, Dec 5, 2006 IP
  4. avkinfo

    avkinfo www.senpai-it.com

    Messages:
    281
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks guys, Ill try it out.
     
    avkinfo, Dec 5, 2006 IP
    dilute likes this.
  5. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #5
    If you have access to php...

    Maybe you can store the source you want to display in a file and using both get_file_contents() and htmlspecialchars() display the source. The second function will replace the < with &lt; and the others aswell.
     
    chopsticks, Dec 6, 2006 IP
  6. dilute

    dilute Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    it's file_get_contents
     
    dilute, Dec 6, 2006 IP
  7. ophir.oren

    ophir.oren Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If you're building a teaching website or trying to teach something I recommend putting it inside a textbox - that will make it easier for the user to copy & paste the code in order to try it out.
     
    ophir.oren, Dec 6, 2006 IP
  8. mich_alex

    mich_alex Well-Known Member

    Messages:
    511
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    108
    #8
    or you could put it in textarea..fieldset
     
    mich_alex, Dec 6, 2006 IP
  9. avkinfo

    avkinfo www.senpai-it.com

    Messages:
    281
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    actually I am trying to get it in a blog post.
     
    avkinfo, Dec 6, 2006 IP