473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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
Jul 20 '05 #1
8 13420


Martin Ernst wrote:
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


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

--

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

Jul 20 '05 #2
Martin Ernst <m.*****@connect-wa.de> wrote:
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?
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.
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.


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 <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #3
Steve Pugh <st***@pugh.net> schrieb:

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;


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

Martin
Jul 20 '05 #4
Martin Ernst wrote:
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?


Replace the < and > characters with their respective entities (&lt; and
&gt;).
Jul 20 '05 #5
Martin Ernst wrote:
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.


Do you have PHP ?

then you could use:

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

should work...

Jul 20 '05 #6
Karsten Tholema wrote:

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


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

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

Jul 20 '05 #7
Martin Ernst <m.*****@connect-wa.de> wrote:
I want to show HTML source code in my browser (for debugging
purposes).


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

Jul 20 '05 #8

"Martin Ernst" <m.*****@connect-wa.de> wrote in message
news:f5********************************@4ax.com...
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?
Why don't you just use View Source or equivalent command?

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


Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Guoqi Zheng | last post by:
Dear sir, I am writting an WYSIWYG html editor, I need to get the html source code out of an iframe. I know I can use innerhtml or innertext. But that will remvoe the html header info which is...
4
by: Steve Slax | last post by:
Hi all. I've a problem: I need to retrieve (in javascript) the soure HTML code from a url without loading the page then put the HTML source code in a string variable to manipulate it. From this...
1
by: ujwala | last post by:
I am trying to develop a tool which requires the source(html) code of the web page i open in the browser.so is there any way to get the html source code of the web page as soon as i open it and store...
4
by: Luk | last post by:
Hello, i need to get a string / some strings from a html source code (external) url: http://wow.buffed.de/?c=2170577&tab=8 there are under "Scherbenwelt" these strings: Ehrenfeste
0
by: kishorrahate | last post by:
Hi, Can anyone know How to retrieve HTML source code using VB script? Thanks, kishor
0
by: jainshasha | last post by:
hello friends well i have create a program which can read out the html source code files or any other web page source code files through my program so please guys help me out in this problem...
2
by: dasrasmikant | last post by:
Hello, I want to print the HTML source code in that page by clicking on a button. So can it possible???
1
by: anuragdak | last post by:
i m working on wrapper generation algorithm and i want any method to convert html source code to DOM tree for it..and how to store it can anybody can suggest any source code or API or any link. ...
3
by: Developer111 | last post by:
I have a problem that IE6 is not loading the whole page i.e. in accordance with my own generated HTML Source Code, but the same is working fine/well in case of IE8 and Mozilla FireFox.
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.