Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 05:28 PM
Martin Ernst
Guest
 
Posts: n/a
Default Hot to output HTML Source Code

Hello.

I want to show HTML source code in my browser (for debugging
purposes). Which tag/formatting di i have to use to tell the browser
not to render the code but display it as pure text?

E.g.

I want
<p>Hello World</p>
to be displayed in the browser.

I have tested <code><p>Hello world</p></code>, but that doesn't work.

Waht can I do? Thanks in advance
Martin
  #2  
Old July 20th, 2005, 05:28 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: Hot to output HTML Source Code



Martin Ernst wrote:[color=blue]
> I want to show HTML source code in my browser (for debugging
> purposes). Which tag/formatting di i have to use to tell the browser
> not to render the code but display it as pure text?
>
> E.g.
>
> I want
> <p>Hello World</p>
> to be displayed in the browser.
>
> I have tested <code><p>Hello world</p></code>, but that doesn't work.
>
> Waht can I do? Thanks in advance[/color]

Escape the tag characters < and >, as in
&lt;p&gt;A paragraph.&lt;/p&gt;

--

Martin Honnen
http://JavaScript.FAQTs.com/

  #3  
Old July 20th, 2005, 05:28 PM
Steve Pugh
Guest
 
Posts: n/a
Default Re: Hot to output HTML Source Code

Martin Ernst <m.ernst@connect-wa.de> wrote:
[color=blue]
>I want to show HTML source code in my browser (for debugging
>purposes). Which tag/formatting di i have to use to tell the browser
>not to render the code but display it as pure text?[/color]

If you want the whole page to be seen as code then you can configure
your server to serve it as text/plain rather than text/html. However,
IE will still parse it as HTML; better browsers will display it as
plain text.
[color=blue]
>I want
><p>Hello World</p>
>to be displayed in the browser.
>
>I have tested <code><p>Hello world</p></code>, but that doesn't work.[/color]

That tells the browser that the enclosed content is code, which is a
good thing. However, it doesn't tell the browser tos top parsing it
for HTML tags.

You need to convert all the isntances of < to &lt;
In some cases you also need to convert > to &gt; and wether you do so
in all cases is up to you.

&lt;p&gt;Hello World&lt;/p&gt;

(You'll also need to convert & to &amp; so that &copy; would be
&amp;copy; and would be displayed as &copy; rather than as teh
copyright symbol.)

There's also the very old, <xmp></xmp> element but that's been
obsolete since HTML 2, isn't supported by all browsers and really can
not be recommended.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <steve@pugh.net> <http://steve.pugh.net/>
  #4  
Old July 20th, 2005, 05:28 PM
Martin Ernst
Guest
 
Posts: n/a
Default Re: Hot to output HTML Source Code

Steve Pugh <steve@pugh.net> schrieb:

[color=blue]
>You need to convert all the isntances of < to &lt;
>In some cases you also need to convert > to &gt; and wether you do so
>in all cases is up to you.
>
>&lt;p&gt;Hello World&lt;/p&gt;
>[/color]

As it seems, I have no choice. Thanks for your answers.

Martin
  #5  
Old July 20th, 2005, 05:28 PM
Owen Jacobson
Guest
 
Posts: n/a
Default Re: Hot to output HTML Source Code

Martin Ernst wrote:
[color=blue]
> Hello.
>
> I want to show HTML source code in my browser (for debugging
> purposes). Which tag/formatting di i have to use to tell the browser
> not to render the code but display it as pure text?[/color]

Replace the < and > characters with their respective entities (&lt; and
&gt;).
  #6  
Old July 20th, 2005, 05:28 PM
Karsten Tholema
Guest
 
Posts: n/a
Default Re: Hot to output HTML Source Code

Martin Ernst wrote:
[color=blue]
> Hello.
>
> I want to show HTML source code in my browser (for debugging
> purposes). Which tag/formatting di i have to use to tell the browser
> not to render the code but display it as pure text?
>
> E.g.
>
> I want
> <p>Hello World</p>
> to be displayed in the browser.
>
> I have tested <code><p>Hello world</p></code>, but that doesn't work.[/color]

Do you have PHP ?

then you could use:

<?php
echo htmlentities(<p>Hello World</p>);
?>

should work...



  #7  
Old July 20th, 2005, 05:28 PM
Jim Dabell
Guest
 
Posts: n/a
Default Re: Hot to output HTML Source Code

Karsten Tholema wrote:

[snip][color=blue]
> <?php
> echo htmlentities(<p>Hello World</p>);
> ?>[/color]

Getting a bit OT here now, but that should be:

<?php
echo htmlentities('<p>Hello World</p>');
?>


--
Jim Dabell

  #8  
Old July 20th, 2005, 05:29 PM
Jukka K. Korpela
Guest
 
Posts: n/a
Default Re: Hot to output HTML Source Code

Martin Ernst <m.ernst@connect-wa.de> wrote:
[color=blue]
> I want to show HTML source code in my browser (for debugging
> purposes).[/color]

What debugging? Which software would you debug that way?

(Just a rhetoric question. Usually people ask the question when they wish to
tell others which HTML code they should use. But it would be reasonable to
expect you to know HTML yourself before trying to teach it to others.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

  #9  
Old July 20th, 2005, 05:29 PM
Harlan Messinger
Guest
 
Posts: n/a
Default Re: Hot to output HTML Source Code


"Martin Ernst" <m.ernst@connect-wa.de> wrote in message
news:f5lcqvcv3uafn1vc2p5u0mdto56bk72c8i@4ax.com...[color=blue]
> Hello.
>
> I want to show HTML source code in my browser (for debugging
> purposes). Which tag/formatting di i have to use to tell the browser
> not to render the code but display it as pure text?[/color]

Why don't you just use View Source or equivalent command?
[color=blue]
>
> E.g.
>
> I want
> <p>Hello World</p>
> to be displayed in the browser.
>
> I have tested <code><p>Hello world</p></code>, but that doesn't work.
>
> Waht can I do? Thanks in advance
> Martin[/color]

 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles