Wrapping text between <xmp>

A

Arnoud Oortwijk

suppose following code

=========================

<table border="1" width="256">

<tr>


</td></tr>

</table>

=========================

I want to show everything between <xmp> and </xmp> in other words I don't
want the JavaScript to be executed. But I also want the table to be no wider
than 256 and the text to be wrapped.

How can this be done?

All help will be greatly appreciated.

Regards,

Arnoud
 
S

Steve Pugh

Arnoud Oortwijk said:
suppose following code

I'd rather not...
<table border="1" width="256">
<tr>

</td></tr>
</table>

Looks like you're using a table for layout. Don't.

<xmp> was marked as obsolete in HTML 2.0 and doesn't exist at all in
modern versions of HTML. You can not expect browsers to support <xmp>
for ever. The code above doesn't stop Opera 7, for example, from
parsing the JavaScript.
I want to show everything between <xmp> and </xmp> in other words I don't
want the JavaScript to be executed. But I also want the table to be no wider
than 256 and the text to be wrapped.

How can this be done?

<div style="width: 256px; border: 1px solid black; padding:
0.5em;"><code>&lt;script language="JavaScript"&gt; window.location =
"http://www.disney.com"; &lt;/script&gt;</code></div>

Obviously you can move the styles into a stylesheet.

The <code> element just marks this up as computer code - most browsers
will display it in a monospaced font, but otherwise it will have no
effect on rendering (so unlike with <xmp> or <pre> the text will
wrap).

Including a few spaces in the code will also help it to wrap better.

Converting the < to &lt; makes them text and not the start of a tag.
There's no actual need to convert > to &gt; in most cases (including
this one) but it does no harm either and there may be browser bugs out
there that make it better safe than sorry to do so.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top