473,657 Members | 2,534 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>Hell o world</p></code>, but that doesn't work.

Waht can I do? Thanks in advance
Martin
Jul 20 '05 #1
8 13434


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>Hell o 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.*****@connec t-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>Hell o 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;Hel lo 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;Hel lo 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>Hell o 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.*****@connec t-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.*****@connec t-wa.de> wrote in message
news:f5******** *************** *********@4ax.c om...
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>Hell o 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
9919
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 what I need. html header may contains reference to base url or style sheet information. How can I get the full source code out of an iframe??? --
4
1476
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 variable I need to get all the links to perform some operations. Everyone have an idea? Thanks.
1
1380
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 the code in a file?
4
9988
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
990
by: kishorrahate | last post by:
Hi, Can anyone know How to retrieve HTML source code using VB script? Thanks, kishor
0
1039
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 that how python can help me in this regard and if there is any other language through which i can easily make my program Thanks in advance
2
1384
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
3464
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. plzzzz its urgent
3
1647
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.
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8516
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.